Firebug debugging fallback

| | Comments (0) | TrackBacks (0)
Firebug is the best tool for debugging heavyweight javascript web applications. You can put console.log(arguments) here and console.debug(foo) there, but ... YOU SHOULD NEVER FORGET TO REMOVE IT! If you forget it, your application stops working in any browser that doesn't know those methods. To avoid this, just include this snippet:
if(!window.console || !window.console.firebug) {
    window.console = {
        debug: function(){},
        log: function(){}
    };
}
/Edit: I just found http://getfirebug.com/firebug/firebugx.js which is more complete:
if (!window.console || !console.firebug)
{
    var names = ["log", "debug", "info", "warn", "error",
                 "assert", "dir", "dirxml", "group",
                 "groupEnd", "time", "timeEnd", "count",
                 "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}

0 TrackBacks

Listed below are links to blogs that reference this entry: Firebug debugging fallback.

TrackBack URL for this entry: http://www.pqpq.de/mt-tb.cgi/4

Leave a comment

About this Entry

This page contains a single entry by Johannes Plunien published on July 29, 2008 7:12 AM.

Remote form validation was the previous entry in this blog.

irssi: Close all queries is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.