Web 2.0 ASP.NET

A Blog about ASP.NET, MVC, Web 2.0, AJAX, SQL server and other web technologies.
Helping the little guy win!

Google Hosts JQuery, Scriptaculous, Prototype and Even the Yahoo User Interface Library

Introduction
For the AJAXians and Web 2.0 citizens amongst you, the wonderful peeps at the Googleplex have done it yet again. Those of you familiar with the concept of NOT reinventing the JavaScript wheel should already be (if not should be) reaping the benefits of the great JavaScript libraries out there. My personal weapon of choice is JQuery (for which you can even get intellisense for in VS2008 these days, check out Scott Gu's blog even if you are not interested in JQuery intellisense, it’s probably the best ASP.NET blog out there).

Anyway, I digress, one of the problems with these libraries is that they often change frequently and while we all try to keep on top of the changes and new builds even the best of us can miss one. Not only that, having to host the libraries in your projects and then changing code to support a new release can mean that users may still have cached versions of the old JavaScript files stuck in their temporary internet files causing JavaScript errors and in the worst case rendering your AJAX masterpieces unusable.

Enter the Google AJAX Library API
The guys at Google have reached out to the major stakeholders in these libraries and are now hosting the different builds of the Libraries for direct loading from google servers. They have committed to maintaining the older versions of these libraries too so there is no chance you can find yourself a couple of JavaScript files less than an application (nice nerdy euphemism there). The cache headers are also set correctly, so this means that you will not have any cached JavaScript issues either.

Setting it all up
Setting it up couldn’t be simpler:


<script src="http://www.google.com/jsapi"></script>
<script>
// Load jQuery
google.load("jquery", "1");
</script>


Yes that really is it! For the performance connoisseurs out there, you can choose to add this at the end of your page so the scripts load last (provided nothing is required in the page load).

Plus you can add as many libraries as you like using google.Load (go for it load the whole lot!)


<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.3.0");
google.load("jqueryui", "1.5.3");
google.load("prototype", "1.6.0.3");
google.load("scriptaculous", "1.8.2");
google.load("mootools", "1.2.1");
google.load("dojo", "1.2.3");
google.load("swfobject", "2.1");
google.load("yui", "2.6.0");
</script>


For more information see the complete API documentation at google:

Google AJAX Libraries API

Happy scripting!

kick it on DotNetKicks.com

1 comments:

blacksnoopy said...

That's awesome

Now Reading







Disclaimer

All data and information provided in THIS blog is for informational purposes only. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis. All code may be used under the standard UIIYW BDBMIITDW license (Use It If You Want But Dont Blame Me If It Doesnt Work) :)