Hosting your jQuery framework – locally or remotely?

There are quite a few reasons why it’s a good idea to reference a framework such as jQuery via a remote CDN.

Upgrades: It is much easier for me to upgrade client sites to the latest version. No files to upload, just change the parameter that determines the version to be downloaded.

Caching: The bigger the files get, the more benefit you’ll get from using a CDN. Users will download and cache the file from Google, and not download the same version of jQuery (or one of the other libraries) from each site they visit.

Latency: What this means is that web users not physically near your server will be able to download jQuery faster than if you force them to download it from your arbitrarily located server.

Better parallelism: browsers limit the number of connections that can be made simultaneously. Depending on which browser, this limit may be as low as two connections per hostname.

So you can reference the jQuery framework like this;

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

OR

<script src="//ajax.googleapis.com/ajax/libs/jquery/latest/jquery.js" type="text/javascript"></script>

Note: Use this method (it’s called protocol-less) if your developing on a server. If your locally accessing the file (file:///), then it’s not going to work.

Other instances

There are other implementations out there. A personal favourite of mine is HTML5 Boilerplate and they reference jQuery on the Google CDN with a local reference fall-back. That’s a superb web skeleton that I’ve also used to build a modern website.

WordPress

To implement this on your WordPress website many have recommended Jason Penney’s WordPress plugin and I don’t think you can go far wrong with it either.

Developer Note

Dave Ward (Encosia) has a comprehensive list of over 100 other mentions of the advantages of using this method.  If ever you need further justification to point to a CDN or get your company to and this article isn’t enough, look no further.

So what are you using currently, what do you prefer and why? Have you noticed any performance differences?

About Desi Reuben-Sealey


Desi is a UXC currently doing UX/UI Black Ops for applications, mobile and web, is a enthusiastic PADI scuba diver, a retired pro UK basketball player, Neo Soul music lover, an enthusiastic charity worker who likes to give to others is various ways.

Short URL: http://bit.ly/LQnFJ4
QR Code:

One Comment

Leave a Reply