JQuery: Using the right CDN
I was reading an article called 6,953 reasons why I still let Google host jQuery for me – which is a scentific experiment to find out which CDN is used by the world’s top sites for JQuery.
Knowing which CDNs are popular is really important. For instance, let’s say you’ve decided to choose Microsoft to host your JQuery CDN.
The whole point of CDNs is that by the time they get to your site, hopefully the user has already picked up the JQuery file (or any other resource) and has it in their cache. This results in a quicker load time on your site, and a better experience. (oh, and possibly you can decrease your hosting traffic costs).
Common sense dictates that the more sites use the same CDN as you, the more likely it is that by the time they get you they will already have everything they need. For the most popular sites on the web, this is even more true.
So, how many other sites are using the Microsoft CDN? Well, in Sept 2010, only 1 of the top 1000 sites (microsoft.com)
According to the research, back in 2010, you need to use the Google CDN, because:
- 47 of the Alexa top 1,000 include a Google CDN reference.
- 99 of the Alexa top 2,000 reference jQuery on the Google CDN.
- 6,953 of the top 200,000 sites include a script reference to some version of jQuery hosted on Google’s CDN
But I was thinking, that’s very US-orientated. For a UK site, with a predominantly UK audience, maybe there’s a variance? Maybe, there’s a secret, commercial, UK-based CDN we don’t know about that everyone in the know is using? Maybe UK sites don’t use CDNs?
So, I tried to re-create the experiment using UK sites. I could only find a good list of the first 100 sites in the UK, from Google. I didn’t want to use Alexa, it’s not great, and it feels to US-based.
I scanned all the sites, counting both how many script tags they had, and how many of those had some reference to “jquery” in the src.
This isn’t totally accurate because I noticed some sites (like the BBC) do some clever version-sniffing before loading locally, but for the most part, it probably is.
All the raw data is available at the end, because it’s very possible I have made some mistakes. If I have, please let me know.
Only 37 of the top 100 sites have a reference to some sort of JQuery library on their homepage.
Only 4 sites in the 100 reference the Google CDN (virginmedia.com, play.com, nationalrail.co.uk, expedia.co.uk). And, they all reference different versions!
Almost everyone else hosts their own version of JQuery locally.
This is fairly rubbish news for the rest of us, trying to keep our sites fast. There don’t seem to be many well-pumped CDN resources out there that are being used by the big guys.
Maybe we should start linking to some of the privately hosted libraries of the larger sites, accepting the risk that one day they may move or delete them without notice?
Or maybe, my sample size isn’t big enough? Maybe I need to get a better list, and scale up to 200,000 sites.
I think I might have another look at the Alexa list and see if I can be convinced of its usefulness. If I rerun the tests with better data, I’ll let you know.
Here’s the raw data: Top100Sites-JqueryUse