You are here: irt.org | FAQ | JavaScript | Source | Q1011 [ previous next ]
Each JavaScript source file is downloaded into the browsers cache at the time it is requested - whether or not your code actually makes reference to the functions in the source files.
Depending on how much memory has been allocated by the user for their memory/harddisc cache, the source files will be stored in the cache. There will remain there even if the browser location changes.
There is obviously an overhead in downloading code that you don't require. You might want to rationalise the code either by not downloading all four source files, or removing functions that are not needed.
However, if the code is used throughout your site, and you always refer to the same JavaScript source files, then it could well be argued that if you expect your visitors to browse through your site, that downloading all four at once, in anticipation, is a good thing.
Just bear in mind that it will slow down the rest of your page - the browser waits for each source file to downloaded before procceding with the rendering on the rest of the page - mainly because there could be JavaScript code that writes to the document.