Google Hosts Popular JS Libraries on CDN
In the Google-loves-me department, Google is now hosting common Javascript libraries on its Content Distribution Network (CDN).
A CDN is a system of distributed content on a large collection of Internet servers on which copies of content are replicated and cached. So when somebody in Germany’s browser requests a document, she/he will have quicker access on a close CDN server than if it resided on one web server far, far away. Plus, Google’s servers are, well, pretty darn likely faster than yours.* Further, by spreading out your requests to different servers you are getting around the browser limit of ~2 concurrent requests/server, which also speeds things up a tad. Finally, you get a speed boost due to caching - if you have a dozen sites referencing a Javascript library on the CDN, the customer only has to load it once. Which all adds up to faster.
What libraries are included:
Which is to say pretty much all of the biggies. According to Google:Google works directly with the key stake holders for each library effort and accepts the latest stable versions as they are released. Once we host a release of a given library, we are committed to hosting that release indefinitely.Which means (a) you won't be twiddling your thumbs waiting for Google to host the latest release, and (b) you can reference any previous version of a library to maintain compatibility.
All you need to do to load a library is:
<script src=“http://www.google.com/jsapi”></script> <script> // Load jQuery google.load(“jquery”, “1.2.6″) ; </script>The latest version of jQuery is now loaded.
I tried this on one of my sites, and it works fine. It’s hard to see a huge speed difference for a ~22kb jQuery library when you’re thumping the requester with a ~200kb OpenLayers library, but it did seem a little quicker.
*Or mine. I’m on Windows boxes over here for pete’s sake. Just last week IIS on one of our boxes decided to get amenesia after a reboot and we had to recreate dozens of site settings from our copious documentation (read: memory and customer complaints). Sometimes I think Windows boxes are like the people on Aliens who are about to have acid-lizards burst through their chests, begging to be shot.