"Christopher Benson-Manica" wrote in message
news:d9**********@chessie.cirr.com...
We have a fairly large (1500 line) .js file that contains script that
most of our pages use. My personal opinion is that this is not
easy to maintain, but others are concerned that with the script placed
in separate smaller files the web server will have to process several
other requests for script files, which will impact the performance of
the server. Is that concern well placed? If so, is there some other
way to break up a large script source file to make it easier to
maintain?
A case could be made that fewer http requests is better but that logic
taken too far will degrade maintainability. Other factors that I consider
when organizing .js files for my teams:
1) Do different pages/screens use sharply differentiated scripts? If so,
divide the scripts according to how they are partnered rather than
favoring a project-wide .js file.
2) If it is likely that scripts may have to be altered, having them all in
the same file can complicate troubleshooting problems during
development. Consider also the situation where different people are
simultaneously creating or altering script functionality.
3) Must some scripts be parsed as the page loads while others need
only be parsed when called? If so, divide them along these lines too
and take advantage of the 'defer' attribute to speed page display.
In general, I have never seen any performance advantage in throwing
everything into one file and other factors, as above, can be important.
Brett Merkey
http://web.tampabay.rr.com/bmerkey/