I do this too but without a plugin, I simply set an empty function for console.log on prod env.
console.log = function(){}
beside console sometimes people also use alert to test something. In some of our webapps we disabled alert the same way like above.. (someone once pushed alert("curse word") on friday in production, it popped up when user did something special. We got interesting mails on monday... ;)
That's annoying as hell for anyone developing downstream code (browser extensions etc.) to be compatible with your site/web app. Much better to use lint rules or an approach like the one mentioned in this article.
I do this too but without a plugin, I simply set an empty function for console.log on prod env.
beside console sometimes people also use alert to test something. In some of our webapps we disabled alert the same way like above.. (someone once pushed alert("curse word") on friday in production, it popped up when user did something special. We got interesting mails on monday... ;)
That's annoying as hell for anyone developing downstream code (browser extensions etc.) to be compatible with your site/web app. Much better to use lint rules or an approach like the one mentioned in this article.
Suggestions are always welcome, keep it up. 👍
nice! approach I'm gonna try it next time 👌
consol.log harming by the way when client assign her own function to grab information
with overwrite our cleaning in client side.
Just curiously, wouldn't that that prevent from errors beings logged if ever you're using something like Sentry or DataDog or NewRelic to log errors ?
What about?
globalThis.console = { log: () => {} };
What will happen when I use
console.info()
for example?Calling info() will cause an exception.
So a better approach would be to do the following if you are only interested in silencing console.log:
It's helpful you called this out.
Wow Im newbie and wanna know how I can use this.
type just like normal console.log()?
Welcome! keep learning & chill 😎