Graceful Degredation of Your Firebug-specific Code

// code yanked from the Yahoo media player. Thanks, Yahoo.
if (! ("console" in window) || !("firebug" in console)) {
    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() {};
}

4 comments ↓

#1 Green on 01.28.08 at 7:53 am

Well, this code is provided by Firebug itself, see http://www.getfirebug.com/lite.html.

#2 Eyal Mrejen on 01.28.08 at 10:09 am

Eh....
Actually it's here:
http://www.getfirebug.com/firebug/firebugx.js

#3 Paul Irish on 01.28.08 at 10:12 am

Eyal, you're right! Funny since, I've used that file plenty before.. though sometimes I catch some nasty IE bugs when I use it.
This code still uses "console" in window instead of just checking window.console so there might be a diff. Let me take a peek.
Thanks!

#4 Eyal Mrejen on 02.05.08 at 8:04 am

No worries