Julian Lannigan

console.log() – A lightweight Firebug error protection function { 0 }

I did some searching for a function to keep IE from barking at the user if they didn’t have Firebug or Console API in their browser.  And their are a ton of simplistic functions that turned up that usually just cover the log, warn, error, and info functions of the console API.  I like to use the trace, assert and grouping functions with my JavaScript, just because I am a code nazi when it comes to debugging a site full of AJAX.  Let me tell you grouping debug messages is a life saver sometimes!

I needed a quick small function that declares all the available functions in the Console API, when the API is not available in the browser. I did not necessarily want a “wrapper” function for the current project I was working on. Here is the code used to protect non-Console API browsers from freaking out when they come across a


The browser will just run an empty function.

    var a = function(){};

Compressed version:

*8 is bit of an improvement, but it’s still Internet Exploder (I’m sorry Explorer).

Be Sociable, Share!

Leave a Reply