Greasemonkey script to turn on Firebug debugging for Dojo
Posted by Shane O'Sullivan on January 12, 2007
Enabling debugging in Dojo is a relatively simple thing to achieve, you simply put
into a script block before including the dojo.js file, and that’s it. If you want to use Firebug to display your debug statements, put the code:
somewhere on the page. However, this is not always as straightforward as it seems. For simple html or PHP pages, sure, it’s easy. But what if you want to debug multiple pages and you’re using static html? You’ll have to put this code on all of them, and remove it when you’re done. Or what, as is the case in my current position, you are working with a very large framework that doesn’t easily allow you to change the template of a page without a long rebuild step?
The solution is to use a Greasemonkey script to enable Dojo/Firebug debugging on any page you visit, or only for pages in a given list of domains (not that this only works for Firefox, poor old IE doesn’t have anything nearly as cool as Greasemonkey available). The steps to use this script are as follows:
- Install Greasemonkey from http://greasemonkey.mozdev.org/
- Install Firebug from http://www.getfirebug.com
- Go to http://userscripts.org/scripts/show/9424 and click the “Install this Script” button. Greasemonkey should prompt you to install it.
That should be all that’s necessary. Now, every page you visit will print it’s debug output to the Firebug console, regardless of whether the page has debugging switched on or not. Obviously you don’t always want this script to run, so to disable it, in Firefox to to “Tools/Greasemonkey/Manage User Scripts”, select the script and uncheck the “Enabled” checkbox whenever you don’t want to use it. Even simpler, if this is the only script you use with Greasemonkey, you can enable/disable Greasemonkey completely by clicking on the monkey icon at the bottom-left of the Firefox window.