Is there any REAL touchable benefit of using the Google jQuery hosted library? Or shall we just download it to our server?
What are your opinions on this?
Webmasters Stack Exchange is a question and answer site for webmasters. It only takes a minute to sign up.Sign up to join this community
There are two major benefits to using an external CDN such as Google to host jQuery:
Using CDN(s) to shard your dependencies across many servers like this in essence represents a tradeoff between bandwidth and latency, assuming you only care about performance.
I'm incidentally assuming the alternative is not simply hosting it locally, but concatenating it with a different local request - there's usually no good reason not to concatenate when you can.
If bandwidth is infinite, then you're best off NOT sharding, because you'll be as slow as your slowest service - since latencies aren't perfectly predictable, with enough services, even if they're fast, you just need one bit of bad luck to cause a slow page load.
If latency is 0, then spreading your load over many servers can improve bandwidth by utilizing many servers (not that helpful since likely the bandwidth limitations are near the clients, not the servers), but more importantly, it can reduce the amount of data transmitted slightly by increasing the effectiveness of caching.
It depends on your scenario, but I'd generally expect latency to be more of an issue than bandwidth, unless your scripts are insanely huge (which jquery is not). At that point, it's usually faster to host jquery as part of a concatenated local file.
Reasons not to host locally are e.g. when you pay for bandwidth, or you're hosting on some slow server (your connection to the client is bottlenecked on your side, not the client's), or you know your clients will have a really low bandwidth (low-end dsl or modems, say - mobile tends to have more latency issues than bandwidth issues), or your clients pay for bandwidth (e.g. mobile) and scripts are a such a noticeable portion of that that minor caching wins matter (not likely).
In any case: far more relevant will be whether you've covered the basics first; appropriate caching headers, concatenation, minification, and gzipping (preferrably with a high compression ratio). And here's the crux: if you DON'T do that, then at least the CDN will, so that's win...
TL;DR: If you have concatenation+minification+gzipping+caching all covered, then serving small scripts locally is faster than from a CDN despite the CDN's better performance - but only if you've done your homework, possibly not on the first page load, and there are definitely exceptions to this rule.