You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since IE7 is dead I don't think it's necessary anymore. Unless you're using methods in production that other browsers will throw exceptions on. Unclear which these are just yet.
Remove console statements before shipping to production
Since IE7 is dead I don't think it's necessary anymore.
It is dying but not dead (unfortunately). And there are still developers who develop for it (that's my case for example). So when necessary, it can be useful to create a "empty" console object and populate it with no-operation methods when necessary. Basically:
// Creates a console object when the browser does not provide the Console API// and populates the console object with an empty function when the API is not complete.(function(){varmethods=["log","info","debug","profile"/*, ... */];if(!window.console)window.console={};varnoop=function(){};for(vari=0;i<methods.length;i++){varmethod=methods[i];if(!console[method])console[method]=noop;}})();
Remove console statements before shipping to production
Important to note also that the follow evaluates to true in all versions of IE prior to 10:
"undefined"===typeofconsole
Once the console has been opened (attached), the condition will evaluate to false. The condition is false in IE10+ whether the developer tools (primarily the console) have been opened or not.
Activity
fflorent commentedon Oct 7, 2013
Hi Paul,
It is dying but not dead (unfortunately). And there are still developers who develop for it (that's my case for example). So when necessary, it can be useful to create a "empty" console object and populate it with no-operation methods when necessary. Basically:
Sure!
Florent
jonathansampson commentedon Jan 4, 2014
Important to note also that the follow evaluates to
truein all versions of IE prior to 10:Once the console has been opened (attached), the condition will evaluate to false. The condition is false in IE10+ whether the developer tools (primarily the console) have been opened or not.
bkardell commentedon Jan 4, 2014
+1 @jonathansampson - it's actually noted as noted in goals already https://github.com/DeveloperToolsWG/console-object#goals - but I think it should go in a best-practices piece along with the above and a link to a polyfill or at least 'non-breaking api' like above.
Best version of @fflorent's example in full seems to be https://github.com/h5bp/html5-boilerplate/blob/master/js/plugins.js