Featured Post

ASP Search Stemmer Class

The original stemmer class was developed by Martin Porter to bring words back to their word stems. For example "abilities" would stem to "able", "smelling" to "smell", "I'm awesome" to "damn straight", etc. I couldn't find a Classic ASP version of this so I ported a port ( I'm not even sure if that's...

Read More

Google Javascript Library CDN

Posted by chelfers | Posted in AJAX, JQuery, Javascript, Javascript Libraries, Web | Posted on 04-07-2009

Tags: , , , ,

0

I have a bad habit of clicking the 'view source' option on any page I find remotely interesting or flashy to take a gander at the CSS and Javascript. I am amazed how often I see so many non-compacted includes for CSS and Javascript alike, and not only non-compacted but more often than not more includes than I can count on my two hands.

I understand if you have a simple site with low traffic; you might not really care about bandwidth, or how long it takes your users to load the page, or hell you probably don't even have a test site so it's a pain in the ass to keep track of multiple versions. My issue is with large sites with thousands of visitor a day with 10 include files ranging in thousands of lines of code, non-compacted files, and not a single CDN. I would venture to guess that any site banking on its visitors probably has a test site and most likely even a development site - there really is no excuse except laziness.

How hard is it to throw all of your Javascript in one file, obfuscate and compact it, reduce the overall file size by more than 50%, and reduce the overhead that comes with downloading multiple includes for your users? Sounds like a long process but with programs such as Yahoo Compressor it's actually one simple step.

This was suppose to be a post about Google hosting most of the popular Javascript libraries, but man I suck at not ranting sometimes.

Time for the goods!

Unless you really feel the need to modify any of these libraries there really isn't a good reason why you should not be using the Goog as a free CDN for your most used content. Obviously if you already have your own CDN this post is not meant for you but for the average llamas out there go-to-this-link.

Google AJAX Libraries API

Now because I'm a JQuery fan-boy I will post the easiest way to get it rolling on your site in the compacted version, because again, your site has no real reason to be running any other version.

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

Ta-da! All of your beautiful plugins still work, and best of all you get the help of big brother to serve up your content.

Write a comment