Last Updated: February 25, 2016
·
813
· yeco

Console debug flag.

So you want all the advantages of logging to the console without all the headaches of IE throwing errors if you happen to forget to remove them? Easy. Override the console object and replace whatever methods being used with placeholders. If you want to debug to console, just add “?debug” to the url.

// cancel console unless "debug" exists in the url query string
console_debug = window.location.search.indexOf("debug")>=0 ? true : false;
if (!(console_debug)){
    console = {};
    console.log = function(){};
    console.error = function(){};
}