Tuesday, May 19, 2009

Migrating to dojo 1.3

Recently enough I just pushed some software which included an upgrade to dojo 1.3. Prior to this, I was using dojo 1.0.2, so this migration to the latest version of dojo represented around 2 years of work from the dojo guys.

Having previously migrated from dojo 0.4.3 to a dev build of dojo 0.9 to dojo 1.0.2, I've had my fair share of experience with dojo upgrades. Having previously worked on framework code in a prior job, I'm always ready to try out the latest a greatest versions of frameworks. My main reasons behind the migration to dojo 1.3 were:

1. Official support for Chrome and IE 8.

2. Speed speed speed. I'm not sure what the numbers are like in taskspeed for dojo 1.0.2, but the 1.3 numbers stack up pretty well against some of the major JS toolkit vendors on the market at the moment.

3. I wanted to start exploring some of the new APIs available in dojo 1.3 such as dojo.data, BusyButton, dojo.place and dojo.create

4. Start exploring the dair extensions for integration between dojo and Adobe AIR.

5. Testing. One of the areas where the application I work on is definitely deficient is automated testing. I wanted to start looking into DOH and the dojo robot.

So, I had plenty of reasons to migrate and the move couldn't have gone easier. I honestly only got stung once where once of my custom widgets had a member variable called _created which stepped on the _created member variable in dijit._Widget. The vast majority of headaches were more related to svn and importing the 1.3 version of dojo into my repository than actually migrating my code to use the new dojo APIs. Kudos to the dojo dev team for keeping such a clean and consistent API.

Already looking forward to the 1.4 version of dojo ...

Wednesday, May 6, 2009

plugd and Google Maps

I just started looking into integrating Google Maps into an application. Given the breath of features offered by Google Maps, its no surprise that the JavaScript download is pretty hefty -> ~72KB with an empty cache for main.js. Also, including Google Maps in a page brings down around 20 extra images (depending on the default size of your map).

So, I started looking into ways for deterministically loading Google Maps as there are certain sections of the application I work on where Google Maps is not needed. Looking at the Google Ajax APIs, this seems like the easiest way to load Google Maps (and other Google APIs for that matter):

<script type="text/javascript"


google.load("maps", "2");

Adding plugd into the mix, you can also cut down on loading the Google Ajax API JavaScript using the addScript method:

dojo.addScript("http://www.google.com/jsapi?key=" + key, dojo.hitch(this, function() {
var mapsLoaded = function() {
dojo.publish("/gmaps/loaded", []);
var langArray = dojo.locale.split("-");
google.load("maps", "2", {"callback" : mapsLoaded, "language": langArray[0] + "_" + langArray[1].toUpperCase()});

And code which depends on Google Maps being loaded should listen to the "/gmaps/loaded" topic before trying to access any Google Maps APIs.