SOS

Shane O'Sullivan's technical blog… really ties the room together

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

djConfig={isDebug:true};

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:

dojo.require(“dojo.debug.console”)

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:

  1. Install Greasemonkey from http://greasemonkey.mozdev.org/
  2. Install Firebug from http://www.getfirebug.com
  3. 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.

About these ads

7 Responses to “Greasemonkey script to turn on Firebug debugging for Dojo”

  1. Great Stuff.

  2. Pancu said

    Anyone knows if there is another script for newer releases of dojo? because this one doesn’t work with dojo 1.0.0

    thanks

  3. I haven’t gotten around to updating the script for 0.9/1.0. When I do I’ll post it.

    Shane

  4. Ramon said

    Any progress here? I get the following displayed in the FF3 error dialog:

    Error: dialog1.show is not a function

    This has happened on other GreaseMonkey scripts that attempt to create and show a dialog — maybe this is not supported under FF3?

    Ramon

  5. Sorry no, it’s been more or less at the bottom of my list. I might get around to it in the next few weeks.

    You could have a try at it? It’s not too complex to edit the greasemonkey script

  6. Bruce said

    Is this still maintained?
    WIth current dojo one sees:
    GET http://localhost:8080/mgmt-api/dojoroot/dojo/debug.js

    404 Not Found
    68ms
    dojo.js (line 14)
    GET http://localhost:8080/mgmt-api/dojoroot/dojo/debug/console.js

    404 Not Found
    62ms
    dojo.js (line 14)
    GET http://localhost:8080/mgmt-api/dojoroot/dojo/debug/Firebug.js

    404 Not Found
    38ms

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 535 other followers

%d bloggers like this: