External scripts

stuartpb

New Member
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
 

smoovo

New Member
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.
 

stuartpb

New Member
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
 

smoovo

New Member
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.
 

peterjoys

New Member
# 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).
 
Top