: Google jQuery hosted library - is it any good? 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
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?
More posts by @Kimberly868
4 Comments
Sorted by latest first Latest Oldest Best
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.
Another downside:
Using a CDN allows operator of the CDN to track the sites visitors. That's why they don't cost money.
There are two major benefits to using an external CDN such as Google to host jQuery:
It's faster. It will be certainly be faster than your site, and probably faster than any CDN you set up yourself.
It may already be cached. Lots of sites reference jQuery on Google's CDN as well, so if they visited another site with it before yours, they won't even need to download it.
Potential downsides:
The domain may be blocked (this is quite common in places like China). You can solve this by having a local fallback (see here for how).
The fragmentation of version numbers is quite high, so visitors to your site may have many different versions cached, but not the one you referenced (see here for some recent stats). This is only an issue on the first page load though.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.