When you get to writing a website you inevitably get to the point of needing to include some libraries to help you out. Before now everyone had to go get these libraries in some form or another and include them in their code in their own way. Now with Google’s AJAX Library API you no longer need to host or even track these files down any longer.
The downside to hosting these files yourself is for one, maintenance. Are you sure you are keeping your libraries up to date? Secondly you’d have to host and serve at times a 100k+ file from your site to everyone. This can take some people awhile to get. Why not leverage Google’s CDN to get these libraries distributed to your readers? If your readers are visiting lots of sites that are using this method they will only have to cache one version as well.
For most cases, using this method should speed up your site, your users experience and your development time. It is very simple to implement, let’s take a look at what it takes.
First you need this line no matter what library you want to load.
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
Google’s Documentation for their API has the current list of supported versions and the libraries they are hosting. To load the library you desire it is as simple as this.
google.load("jquery", "1.3.1");
google.load("prototype", "1.6.0.3");
google.load("scriptaculous", "1.8.2");
Quite easy and it saves you a lot of trouble!