Category : Javascript | Author : Chtiwi Malek | First posted : 3/6/2012 | Updated : 3/13/2012
Tags : jquery, javascript, ajax, google, cdn
Why you should use the jQuery hosted by Google’s CDN

Why you should use the jQuery hosted by Google’s CDN

I used to copy the jQuery JavaScript Library inside each of my sites, which was the logical thing to do, until I come across CDNs “Content Delivery nerworks”.

What’s a Content Delivery nerwork ?
A Content Delivery nerwork “CDN” is a network of computers, installed at diverse physical locations, around the globe (for the big ones). They main function of a CDN is hosting and distributing copies of data and files.

The question is: what are the advantages of using Google CDN instead of hosting the jQuery Api on your server(s)?

1- Speeding up your web site load time

Your website’s users will get the jQuery from the CDN, that means less requests to your server and faster download time because the Google CDN is fast, stable, reliable and the jQuery will be downloaded from the nearest available node in the CDN network.

Also there’s a huge probability that your user already has the jQuery file cached on his browser, even if it’s his first visit to your site, because the library is also referenced on other sites. In this case the download time for jQuery will be null.

2- Economizing data bandwidth

The jQuery file (depending on the version) is about 100kb, and that’s the minified version. You can multiply it by the number of your unique visitors and do the math.

I believe that relying on Google CDN is all benefits and the cool thing it’s free of charge.

Here’s the link :
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
Note: there’s no HTTP in the SRC link, this will allow the request to be made in http or https depending on your page’s protocol, but you can add http or https if you want to be more specific.

Google CDN hosts many other versions and open-source JavaScript libraries,
here’s the page : http://code.google.com/apis/libraries/devguide.html
Comments & Opinions :
Public CDN
yes, agree.
public CDN speed up the website load time
- by Joe on 3/16/2012
Leave a Comment:
Name :
Email : * will not be shown
Title :
Comment :