You could surely save few milliseconds if you try to merge or combine all the data in the entire .js file. But remember if each and every document uses only a small part of the script then there is no such necessity of merging, combining data would be senseless and waste. Suppose of you have a .js file of 1.5 MB that has all the Scripts contained in it and if the file contains the following three lines of code:
Code:
function sortCriteria(){
return (a<b?1:b<a?-1:0);
}
Now just let me know whether there is any special of proper reason for loading up the whole 1.5MB file for it. It only recommended to combine the files only if they contains related data like if one function completely depends upon another function, definitely it would be very much senseless to keep both the function saved in two different and separate files. But suppose if you have a script say a banner rotate script and another gallery script which have no common constant functions or anything like that then better you keep then saved in separate files and don’t try to combine together. The same thing is applied for graphics i.e. the sprite images. You could have some huge amount of buttons which is dispersed over the entire site with some 3 or 4 states which gives you the total of 600-800 sprites. If each page use 12 sprites then you will surely have to waste your lot of bandwidth and download time. and if the user keeps on visiting so many pages where during the session majority of the sprites is used then better you combine them; I can only recommend you this and if there is a site where he user visit 1 or 2 pages mostly using some of the sprites then the sprite should be better splitted up over multiple files.
Bookmarks