Backup plan when loading the jQuery library from CDN

Posted on April 20, 2010 by Frederik Vig in JavaScript

In most of my project I load the jQuery library from a CDN, either Google or Microsoft. This ensures that my page will load faster for my visitors, since the jQuery file will get sent to them from their nearest location, gzipped and compressed. When the visitor visits another site that use the same jQuery version from the same CDN, they don’t need to wait for their browser to download the library since it’s already in their temporary Internet files.

One of the drawbacks to this approach is when the CDN goes offline or becomes unavailable. Fortunately this has not happened to me – we should however have a backup plan!

This script will use a local copy of jQuery if jQuery is unavailable from Google in some way.

Related Posts: