External scripts

Discussion in 'Scripts' started by stuartpb, Jan 12, 2011.

to remove all ads.
  1. stuartpb

    stuartpb New Member

    Messages:
    16
    I have seen some cool JS scripts that I wouldn't mind using on my site. For the sake of tidiness, I wouldn't mind just putting them all in one file, and linking to that from the web pages, instead of having 5 or 6 seperate links for each script. I'm not sure which is the best way though, doing it like this, or just keeping everything seperate. Would there be a load time increase on the page, or any other problems?

    Any advice is appreciated.

    Thanks,

    Stu
     
  2. smoovo

    smoovo New Member

    Messages:
    377
    Any kind of file embedding, like JS, CSS, images, etc. will force HTTP request. HTTP requests taking time, and it is better to have low as possible requests.

    If you will have all the JS scripts in one file it will increase your page speed. The thing is, some of the JS codes have to be linked in the header, and some right before the ending body tag. If you have this two kind of scripts, you can make two files, and embed one in the header and one right before the ending body tag. Either way make it all-in-one as possible.

    Another thing is that some pages are not using one or two of this scripts, so adding them to the page will make the page slower.

    Think about it and try to understand and figure what the best solution for your website, and faster is better.

    - Good Luck.
     
  3. stuartpb

    stuartpb New Member

    Messages:
    16
    Thanks a lot for the info, and I've minimised the JS and also the CSS. Load times weren't a problem on the site, but at least I know that everything's optimised.

    Cheers,

    Stu
     
  4. smoovo

    smoovo New Member

    Messages:
    377
    Improve page speed

    My pleasure.

    You can optimize page speed in many ways; Sprites, Images file size (jpg vs. png), Minify Scripts, etc.

    See Google's page speed explanation.

    - Have Fun.
     
  5. stuartpb

    stuartpb New Member

    Messages:
    16
    Thanks again:)

    The google page was a good read, and definitely gave me some good pointers.:)
     
  6. Dorky

    Dorky New Member

    Messages:
    33
    Sprites are segmented and also require further http requests. do you mean sliced?
     
  7. che09

    che09 New Member

    Messages:
    337
    I think everything's well now. Taking smoovo's advice is a good thing!! ;)
     
  8. peterjoys

    peterjoys New Member

    Messages:
    5
    # Use external JavaScript files when you want to use the same script on many pages, but don't want to have to rewrite the code on every page!
    # Use external JavaScript files for including both types of scripts: the type that you place in the head (functions) and the type you place in the body (scripts you want to run when the page loads).
     

Share This Page