Back to Blog

Google’s hosts popular AJAX libraries like jQuery

Author

Lately we’ve been using jQuery more often within our projects. I’ve realized that it becomes a hassle to include the jQuery library for each and every project. When jQuery updates to a newer version it also leaves legacy versions scattered thoughout our projects. As a solution we can make use of Google’s generosity and link to the AJAX Libraries API.

Google’s AJAX Libraries API is basically a fancy way of saying “we host jQuery and other popular JavaScript libraries for you to tap into”. Among the hosted libraries are dojo, mootools, script.aculo.us, prototype, jQuery and even jQuery UI.

This allows us to link directly to a centrally hosted copy of the latest version of jQuery. The hosted version is also compressed and minified for a smaller file size.

If enough people begin to link to the hosted libraries on Google, then there’s a possiblity that your users already have local copy of a JavaScript library cached on their system. This means may decrease the amount of time it takes to load your page.

To load in jQuery hosted by Google you can add the following <script> tag to your document’s <head> section.

XHTML


There are obvious benefits and worries to this approach. For now, I like the idea because it allows me to get started on a jQuery project right away, without having to bring over a new copy.

In the mean time, let’s hope Google doesn’t go down. But we write our JavaScript to degrade gracefully now don’t we, so what’s the point in worrying about something like that.

Related Links

Author

How we work Process

Product Hero Talin Wadsworth