Im building a big project and have a questionthat i cant find a definitive answer for.
Aside from programming cosmetics, and readability.
Lets consider 200 functions, is performance affected by any of the above? Im after maximum performance rather than readbility.
My first thought is that 200 functions in one file would cause a little slow down. But then maybe computers process that as if it were nothing and makes no difference?
I just read Felgall say in another thread that browsers will stop what they are doing while loading a JS script. Then again, calling 200 separate files means 200 separate handshakes with the server.
If you mean, negotiation (some pages need some scripts and others don't), I have seen a dynamic loader as a solution to large scripts, where each page has a little script that calls what's needed for that page from the libs elsewhere... that way, the page who only needs 5 of the files only asks for 5, while the page than needs all 200 asks for those (caching should play a part here too).
I'll see if I can find it. It might have been part of one of the JS libraries.
Cool Thanks Stomme, that could be worth a look!
Hm, I'm not finding it already (but my google-fu is notoriously sucky), but now I wonder if the negotiation was done by the back-end? So that's possible.
In general, you want cacheability, and so few as possible handshakes/calls to the server. So this suggests one giant file... however if only some pages are making use of the file I'd see about the dynamic adding of bits... just saw something about a trick built-into scriptaculous, so it wouldn't surprise me to see that most or all of the big popular libs had something similar.