DrDoc - 4:13 pm on Aug 6, 2013 (gmt 0)
That's an excellent question!
Here are the factors to consider:
You must consider all those factors when making a decision like this.
Is this a script that does something immediately, as soon as the visitor loads the page? Or is it a utility script with functions that are called later?
Is the combined file size only a few bytes, or is it several kilobytes? Due to the way network packet sizes work, the browser may act as if loading a file several times larger than the actual file size.
Frequency of Use
On how many pages is the script used? All? Most? Some?
Number of Unique Visitors
Do you have a lot of first-time visitors? Again, this comes back to the file size. Would they be better served with a fast-loading inline script than waiting for a second HTTP request to fetch the script file?
These last two are really two main factors. In order to benefit from caching, they must visit enough pages to take advantage of the cached script. See the note above regarding file size ... If the effort of downloading an external script is not less than the effort required by the browser to load a few extra bytes embedded within each page, then you have not gained anything by employing caching.
Brought to you by WebmasterWorld: http://www.webmasterworld.com