I use grunt for this.
Here's an excellent tutorial on how to install it and use it to concatenate JS files.
Of course, you could do this manually if you use a lot of libraries that aren't likely to change.
I just put them all in one big file at the bottom of my page. Simple
Yes, not in the <head>: Put Scripts at Bottom (and more "Best Practices for Speeding Up Your Web Site" over there).
- Maybe (1) there are some exceptions, but 99% of the js-files are functioning when put at the bottom; you've to test that before collapsing them into 1 big file. And keep a backup of the separate files: in case of an update of one of them, to make a new big one.
- Maybe (2) some of the js-files come from a content delivery network (CDN), which can be faster downloading than if you put them in the big file on your own server. Again some trials and comparing the test-pages will give the best way, I think.
With my site in my sig I put most of the head section in a include and the same with the bottom. Extremely easy to manage. Because yes sometimes you have a js file that needs to go up top. In which case adding it is so simple.
This topic is now closed. New replies are no longer allowed.