Reputation: 157991
I'm developing a dynamic website using jQuery and I have found several jQuery plugins to be very helpful when doing that.
Of course, for each plugin I add, there is another script to load when the page loads. I know that for pages to be quick to load, smaller and/or fewer resources is better.
Is it safe to just merge all those jQuery plugin files into one? Do I need to check something before I do, or can this even be done quick and dirty by a script on the server-side?
Upvotes: 9
Views: 4161
Reputation: 7139
Yes it is safe to merge them into one.
And in most cases the page should load faster as a result, but there are some situations where doing so might slow things down. For example:
Upvotes: 7
Reputation: 11110
Yes, since your browser does fetching and executing each file, in the order they are included, and concatenating multiple scripts in one file is the same, the browser would fetch that file and execute it.
Upvotes: 0
Reputation: 344291
Yes, it is. That's what will happen in your browser, anyway.
You could also use a minification tool such as the Google Closure Compiler or the YUI Compressor to further reduce the size of your JavaScript code.
Upvotes: 4