Home > javascript > Graceful Degredation of Your Firebug-specific Code

Graceful Degredation of Your Firebug-specific Code

January 27th, 2008
// 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() {};
}

Paul Irish javascript

  1. Green
    #1

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

  2. Eyal Mrejen
  3. #3

    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
    #4

    No worries

For code blocks, use <pre lang="javascript" escaped="true">. css and html4strict are also accepted.

i left this space here for you to play. <3