Google hosting AJAX libraries on their infrastructure
28 May, 2008
Written by James Williams
Maybe about a year or so ago, I remember listening to some podcast where the issue was raised that Google, Microsoft, or somebody should host the different AJAX libraries so that they are properly cached and versioned therefore lessening load time after the first hit. On the eve of Google I/O, Google has answered that call.
You can reference scripts from their absolute path like:
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js"></script>
or you can use the Google AJAX API Loader’s
google.load()
method:
<script src="http://www.google.com/jsapi"></script>
<script>
// Load jQuery
google.load("jquery", "1.2.3");
...
</script>
The currently supported libraries are jQuery, Prototype, Scriptaculous, Mootools and Dojo. Google hosts these libraries on servers all over the world so not only will the download be optimized, it’ll will probably be physically near the user. Yahoo reportedly uses a similar scheme for their YUI libraries.
For Grails, this is extra nice because Prototype is the only bundled Javascript library. Maybe the javascript tag should get some love to point to the Google CDN in the appropriate cases...Just a thought.
Comments
-
paul
said:
I've started using them, but I do most of my work while travelling so I'm offline - so I have a taglib which references local copies for dev, the google ones for prod.
I'm not sure why FireFox checks the server every time - the expiry date is set for one year in the future...
blog comments powered by Disqus