When should you break down your JS into more than 1 file? I would think that you should do it when 1 file gets to meet a certain size, but what would be the advantage of breaking it down in the first place since no matter what, it will be the same amount of memory having to be read by the browser...?
Any info on this would be great. I'm sure I'm missing something here as I have one hell of a thick head when it comes to JS...
The advantage of multiple script files is that you can load a small script before the page is rendered, and use that code to add more code as needed.
It has the biggest benefit on large or frequently updated sites, with many pages selecting from a basic menu of scripts.
Its disadvantages include needing more http requests to load your pages and more code- a lot of it for checking for dependencies before using objects defined in other files.
The biggest advantage in splitting up the JavaScript is to only load those parts that a web page actually uses rather than loading all of it in each page. Progressively loading pieces of code as required is not always necessary but would be a logical next step if your JavaScripts are still too big (say over 7k total combined size).
Bookmarks