Category Archives: cdn

Load jQuery library from Microsoft, Google, Jquery.com CDNs

Hey there,

There are Mainly 3 popular jQuery CDNs.

1. Google.
2. Microsoft
3. jQuery.com

The Main Advantages of using CDN.

  1.  It reduces the load from your server.
  2.  It saves bandwidth. jQuery framework will load faster from these CDN.
  3.  The most important benefit is it will be cached, if the user has visited any site which is using jQuery framework from any of these CDN

load jQuery from CDN

Code to load jQuery library from Google CDN

Code to load jQuery library from Microsoft CDN

Code to load jQuery library from jQuery.com (EdgeCast CDN)

 load jQuery locally when CDN fails

It is a good approach to always use CDN but sometimes what if the CDN is down (rare possibility though). Below given jQuery code checks whether jQuery is loaded from Google CDN or not, if not then it references the jQuery.js file from your folder.

It first loads the jQuery from Google CDN and then checks the jQuery object. If jQuery is not loaded successfully then it will references the jQuery.js file from hard drive location. In the above code, the jQuery.js is loaded from Scripts folder.