Tech News

Thursday, June 26, 2008

Announcing AJAX Libraries API: Speed up your Ajax apps with Google’s infrastructure

Category: Ajax, JavaScript, Library, Google

AJAX Libraries API

I just got to announce the Google AJAX Libraries API which exists to make Ajax applications that use popular frameworks such as Prototype, Script.aculo.us, jQuery, Dojo, and MooTools faster and easier for developers.

Whenever I wrote an application that uses one of these frameworks, I would picture a user accessing my application, having 33 copies of prototype.js, and yet downloading yet another one from my site. It would make me squirm. What a waste!

At the same time, I was reading research from Steve Souders and others in the performance space that showed just how badly we are doing at providing these libraries. As developers we should setup the caching correctly so we only send that file down when absolutely necessary. We should also gzip the files to browsers that accept them. Oh, and we should probably use a minified version to get that little bit more out of the system. We should also follow the practice of versioning the files nicely. Instead, we find a lot of jquery.js files with no version, that often have little tweaks added to the end of the fils, and caching is not setup well at all so the file keeps getting sent down for no reason.

When I joined Google I realised that we could help out here. What if we hosted these files? Everyone would see some instant benefits:

  • Caching can be done correctly, and once, by us... and developers have to do nothing
  • Gzip works
  • We can serve minified versions
  • The files are hosted by Google which has a distributed CDN at various points around the world, so the files are "close" to the user
  • The servers are fast
  • By using the same URLs, if a critical mass of applications use the Google infrastructure, when someone comes to your application the file may already be loaded!
  • A subtle performance (and security) issue revolves around the headers that you send up and down. Since you are using a special domain (NOTE: not google.com!), no cookies or other verbose headers will be sent up, saving precious bytes.

This is why we have released the AJAX Libraries API. We sat down with a few of the popular open source frameworks and they were all excited about the idea, so we got to work with them, and now you have access to their great work from our servers.

Details of what we are launching

You can access the libraries in two ways, and either way we take the pain out of hosting the libraries, correctly setting cache headers, staying up to date with the most recent bug fixes, etc.

The first way to access the scripts is simply be using a standard <script src=".."> tag that points to the correct place.

For example, to load Prototype version 1.6.0.2 you would place the following in your HTML:

HTML:
  1.  
  2. <script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js"></script>
  3.  

The second way to access the scripts is via the Google AJAX API Loader's google.load() method.

Here is an example using that technique to load and use jQuery for a simple search mashup:

HTML:
  1.  
  2. <script src="http://www.google.com/jsapi"></script>
  3.   // Load jQuery
  4.   google.load("jquery", "1");
  5.  
  6.   // on page load complete, fire off a jQuery json-p query
  7.   // against Google web search
  8.   google.setOnLoadCallback(function() {
  9.     $.getJSON("http://ajax.googleapis.com/ajax/services/search/web?q=google&;v=1.0&;callback=?",
  10.  
  11.       // on search completion, process the results
  12.       function (data) {
  13.         if (data.responseDate.results &&
  14.             data.responseDate.results.length>0) {
  15.           renderResults(data.responseDate.results);
  16.         }
  17.       });
  18.     });
  19. </script>
  20.  

You will notice that the version used was just "1". This is a smart versioning feature that allows your application to specify a desired version with as much precision as it needs. By dropping version fields, you end up wild carding a field. For instance, consider a set of versions: 1.9.1, 1.8.4, 1.8.2.

Specifying a version of "1.8.2" will select the obvious version. This is because a fully specified version was used. Specifying a version of "1.8" would select version 1.8.4 since this is the highest versioned release in the 1.8 branch. For much the same reason, a request for "1" will end up loading version 1.9.1.

Note, these versioning semantics work the same way when using google.load and when using direct script urls.

By default, the JavaScript that gets sent back by the loader will be minified, if there is a version supported. Thus, for the example above we would return the minified version of jQuery. If you specifically want the raw JavaScript itself, you can add the "uncompressed" parameter like so:

JAVASCRIPT:
  1.  
  2. google.load("jquery", "1.2", {uncompressed:true});
  3.  

Today we are starting with the current versions of the library, but moving forward we will be archiving all versions from now onwards so you can be sure they are available.

For a full listing of the currently supported libraries, see the documentation.

Here I am, talking about what we are doing in two short slides:


The Future

This is just the beginning. We obviously want to add more libraries as you find them useful. Also, if you squint a little you can see how this can extend even further.

If we see good usage, we can work with browser vendors to automatically ship these libraries. Then, if they see the URLs that we use, they could auto load the libraries, even special JIT'd ones, from their local system. Thus, no network hit at all! Also, the browser could have the IP addresses for this service available, so they don't have the hit of a DNS lookup. Longer lived special browser caches for JavaScript libraries could also use these URLs.

The bottom line, and what I am really excited about, is what this could all mean for Web developers if this happens. We could be removed of the constant burden of having to re-download our standard libraries all the time. What other platform makes you do this?! Imagine if you had to download the JRE everytime you ran a Java app! If we can remove this burden, we can spend more time flushing out functionality that we need, and less time worrying about the actual download bits. I am all for lean, but there is more to life.

Acknowledgements

I want to acknowledge the other work that has been done here. Some libraries such as jQuery and Dean Edwards Base were already kind of doing this by hot linking to their Google Code project hosting repository. We thought this was great, but we wanted to make it more official, and open it up to libraries that don't use our project hosting facilities.

Also, AOL does a great job of hosting Dojo already. We recommend using them for your Dojo needs, but are proud to also offer the library. Choice is good. Finally, Yahoo! placed the YUI files on their own CDN for all to use.

Blogged with the Flock Browser

Wednesday, June 25, 2008

Enable code coloring in Dreamweaver for Drupal by adding file extensions recognized by Dreamweaver

Blogged with the Flock Browser

Tuesday, June 24, 2008

Fighting the Android: Nokia buys and open sources Symbian

Nokia announced plans today to transform the Symbian mobile phone operating system into an open source platform. Nokia, which already owns roughly half of all shares of Symbian, is in the process of obtaining the other half from various holders for €264 million. The company has partnered with several other major handset makers to launch the new nonprofit Symbian Foundation, which will facilitate the liberation of the platform.

Several core Symbian Foundation members are contributing their own Symbian-based technologies so that the best third-party enhancements can be converged into a single unified stack. This will include Nokia's own S60 platform, the UIQ graphical user interface layer which is jointly owned by Sony Ericsson and Motorola, and NTT DoCoMo's MOAP. These components will be available soon under a royalty-free license to all members of the foundation. Within two years, the platform will be completely open source and will be distributed under the Eclipse Public License (EPL), a moderately permissive license that requires downstream patent grants.

"Establishing the Foundation is one of the biggest contributions to an open community ever made," said Nokia CEO Olli-Pekka Kallasvuo in a statement. "Nokia is a strong supporter of open platforms and technologies as they give the freedom to build, maintain and evolve applications and services across device segments and offer by far the largest ecosystem, enabling rapid innovation. Today's announcement is a major milestone in our devices software strategy."

Symbian is currently the most widely-used smartphone platform, but its popularity and relevance have been declining as handset makers moved towards other platforms, including Windows Mobile and Apple's iPhone, as well as Linux and other open source alternatives that reduce licensing costs and offer more flexibility. The Symbian's business model and development strategy were far out of step with the direction in which the industry was collectively moving. Nokia's efforts to completely open the platform will change that and make Symbian a much stronger contender in the next-generation mobile space.

This could give Symbian a competitive boost against other open phone operating systems such as the one created by the LiMo Foundation and Google's Android platform which has reportedly run into a few snags with major carriers.
Fighting the Android: Nokia buys and open sources Symbian

Add to Technorati Favorites

Monday, June 16, 2008

Don’t forget to be part of Firefox’s Download Day!

Mark your calendar, wrap a ribbon around your finger or write a little sticky yellow note. Download Day will start on June 17, 2008.

Blogged with the Flock Browser

Thursday, June 5, 2008

Design Stencils - Yahoo! Design Pattern Library

Download a Stencil KitYahoo! Design Stencil Kit version 1.0 is available for OmniGraffle, Visio (XML), Adobe Illustrator (PDF and SVG), and Adobe Photoshop (PNG), and covers the following topics: * Ad Units * Calendars * Carousels * Charts and Tables * UI Controls * Form Elements * Grids * Menus and Buttons * Mobile - General * Mobile - iPhone * Navigation and Pagination * OS Elements * Placeholder Text * Screen Resolutions * Tabs * Windows and ContainersDOWNLOADOmniGraffleVisio (XML)PDFPNGSVGCreative Commons LicenseThis work is licensed under a Creative Commons Attribution 2.5
Design Stencils - Yahoo! Design Pattern Library
Blogged with the Flock Browser

Subscribe Now: poweredby

Powered by FeedBurner