Several months ago Google released an AJAX libraries API. Basically Google collected the most popular JavaScript libraries, like Prototype.js and jQuery, and is hosting them on their servers behind a CDN and gzipping them. With the exception of Prototype.js they’re also minifying the libraries.
The key benefit, as others have noted before, are that as more sites start using these Google-hosted libraries, visitors to these sites will be able to utilize their browser cache more effectively. If I download jQuery as part of visiting site A, it will be in my cache when I visit site B. The secondary benefit is that CDN plus GZIP plus minifying means that visitors are getting the smallest possible file in the fastest possible time. This greatly reduces the impact of including a 100k+ library on your website.
<script src="http://www.google.com/jsapi"></script>
<script>
// Load jQuery
google.load(”jquery”, “1.3.1″);
</script>
<script>
// Custom site code utilizing jQuery
</script>
At SolutionSet we’re experimenting with extending the Google loader with a “Solution” loader that would do the same thing but for our own favorite libraries such as sIFR and our own custom jQuery extensions that we use from project to project. An exciting prospect of having our own hosted libraries is that we could write inclusion chains into our javascript files, similar to using include_once in PHP.
// File named grady-box.js
solution.load(”box”, “1.0.0″); //this files contains an object named Box
// Use the box
var GradyBox = new Box({height:100,width:100}); // creates a 100×100 px box.
June 13th, 2009 at 1:32 am
[…] Using Google’s AJAX Libraries API (solutionset.com) […]