Error handler being wrongly invoked in callback to

I’ve seen behaviour when using Dojo‘s ajax request handler where a valid response is returned, but it’s error handler is called. This seemed to be an error on Dojo’s part, as all the headers were correct (set to 200 and the correct content type, “text/plain”), but after much frustration, I stumbled on the answer – the load method was being called, but an exception was being thrown. The Dojo code seems to wrap the load method in a try/catch block, and if an exception is thrown, the error function is then called.

So, if you see you error functions being called when they shouldn’t be, stick a try/catch block inside your load function to see if that’s the problem.

Very powerful Javascript compressor called Packer announced

A new version of the Packer utility for compressing Javascript has been released by Dean Edwards and David McNab, and it’s amazing how small it can compress javascript code to. I took a compressed version of Dojo‘s main file, dojo.js and compressed it further with Packer, and it went from 201k to 113k! This is a massive difference, especially given the fact that Dojo’s existing compressor is already very effective – the original code, before it was compressed with Dojo’s compressor, was 409k.

To use this utility, you need two things: Rhino and packer.js .

Rather than download Rhino separately, I used the version that comes with Dojo, though not in the bundled versions. You have to check out the Dojo source code from the Subversion repository (see here for instructions), and Rhino is in the /buildscripts/lib/custom_rhino.jar file. Alternatively, if you don’t want to download the Dojo source tree, you can just download that single jar file from here. Oh, and you’ll obviously have to have Java installed also, as Rhino is Java based.

Using the compressor is extremely simple. Open a command window and type:

java -jar /path/to/custom_rhino.jar packer.js inputfile.js outputfile.js

You’ll be in for quite a long wait, as the compression takes a loooonnnnggg time, but believe me it’s worth it. I wouldn’t recommend building this into your build process that you run on a regular basis, but before releasing production code it would be a good idea to run your files through Packer.

One caveat is that, due to the fact that the resulting file is absolutely bloody tiny, no attempt has been made at making it readable. All new line characters have been removed, all non-global variables have been renamed to someting unintelligible etc, so all you have to read is a single line of apparent gibberish. However, it works perfectly well and, as I previously mentioned, is bloody tiny! So, give it a go, you won’t be disappointed.

Here is a link to a discussion on the topic on the Dojo-interest forum.

Getting started with Ajax on Eclipse

I recently tried to get up and running with the Eclipse Ajax Toolkit Framework, which contains many useful, though very early in development, features to make developing Ajax based applications easier. However, it turned out to be ridiculously difficult to get working. First I downloaded a v3.2 version of Eclipse, got the prerequisites (including the Web Standards Tools package) and tried to install the ATF package, but to no avail. I then tried downloading a bundled version of the WST package and installing the ATF on top of it, and once again it told me I was missing some plugins. Updating the entire platform through the Software Updates tool didn’t help either.

Finally, I found an amazingly simple tool that fixes all this for you. One of the Eclipse partners, Yoxos, has a web-based tool that allows you to configure your own copy of Eclipse, adding in whatever plugins and features you like. They have a list of the most popular configurations, but, unlike the bundled Eclipse distros, they allow you to mix and match different configurations before you download them. Yoxos also saves you the trouble of having to enter in many different update sites for the various different projects of Eclipse, something I always found extremely irritating. Why Eclipse can’t manage to have a single update site that encapsulates every project on, I’ll never know. Yoxos also include other open source Eclipse packages that are not part of the Eclipse project, such as Aptana, a very cool Ajax development environment for Eclipse.

All this very cool, but the ATF has a number of steps you must perform (see here) before it will work. The Yoxos distribution goes some way towards solving these.

  • It automatically downloads a distribution of Dojo and places it in the correct plugin resource folder (eclipse\plugins\org.eclipse.atf.personality.dojo.runtime_1.0.1\resources if you’re interested). Personally I prefer to make my own builds of Dojo, rather than taking one of the canned builds, but that’s a personal choice and the bundled one might do you just fine. Note that Dojo 0.4.0 was just release this week, and you may want to update to that instead.
  • The JsLint javascript file is downloaded to the correct folder (eclipse\plugins\org.eclipse.atf.javascript.jslint_1.0.1\resources), however it is not renamed from fulljslint.js to jslint.js as is required by ATF. So, go to that folder and rename it to jslint.js.
  • XulRunner is not downloaded and installed, so you’ll still have to follow the instructions here to get that part working.

However, these three little steps are miniscule compared to the headaches I had trying to set it up on my own, so give it a go. Some things to note

  1. Yoxos rebrand Eclipse so that their logo pops up in some places. I don’t mind, but some people might.
  2. They also offer an optional second update mechanism, which I prefer to the usual Eclipse tool. It integrates with their web tool to make sure you have all the plugins you need, without you having to enter in the various update sites and resolve the plugin dependancies yourself.


Some issues have come to light since I’ve downloaded from Yoxos and played around with it.

  1. Using the Yoxos update facility (after the initial download) requires you to register with their site, which unfortunately costs money.  So make sure that you have everything you need in the initial download if you don’t intend on paying for their service. The Yoxos update tool also caused Eclipse to crash when it found that I hadn’t bought a subscription, though this appears to be a bug rather than deliberate.
  2. There seems to be some problem with running the Mozilla browser.  When I choose to run a HTML file in the Mozilla browser (using the Ajax Toolkit Framework), the tab for the browser would appear, but the actual window never appeared.  This means that I cannot use the debugging features of the Ajax toolkit.

The closest thing to HelloWorld tutorials in Dojo

Update: I have released the Dojo Demo Framework which has many, many hello world demos. For more info, see

When it comes to documentation (or lack thereof) for the Dojo Ajax toolkit, possibly the most requested item is a set of HelloWorld tutorials that explain the basics of how to get started with each and every facet of the framework, from widgets to the event system and everything in between. What many people new to the toolkit are not aware of is that this does – kind of – exist in the directory of unit tests that are available at These tests cover the basics of how to use all the different parts of Dojo, and while they’re not particularly well commented (noticing a pattern here?), they all do very simple atomic tasks that are quite easy to understand.

Alternatively, you could pull down a copy of the build from Subversion (go here for instructions how) , and all these unit tests are in the /tests folder.