Which solution do you recommend, the second is simpler ( less code ), but there are drawbacks on using it ?
First: (Set a global debug flag)
EDIT: Andy's answer is way more elegant than the quick hack I've posted below.
I generally use this approach...
// prevent console errors on browsers without firebug if (!window.console) { window.console = {}; window.console.log = function(){}; }