Can I do the following to shave milliseconds of loading for some users?
Fix a suitable version x of jQuery, say x = 1.4.1, and find the most recent version y of jQuery cached by the user. Then,
if (y > x === true) {
/* Use the cached version y of jQuery */
} else {
/* Download and use the latest version of jQuery */
}
Also, would this be advantageous?
Caching doesn’t work this way. You won’t know whether or not jQuery is cached in the browser, because it won’t be present in the DOM until you include a script reference to it. If that script reference happens to be to a URL that’s previously been cached in that browser (your odds of this will improve if you’re using a public CDN), then you get the benefits of caching for free.
In short, the only thing you can really do here to optimize “cache hits” is to use a publicly hosted copy of jQuery, like one of these.