Sudantha Sudantha - 5 months ago 22x
Javascript Question

will console.log reduce java-script execution performance?

Will use of the debugging feature

reduce JavaScript execution performance? Will it affect the speed of script execution in production environments?

Is there an approach to disable console logs in production environments from a single config location?


If you are going to have this in a public site or something, any one with little knowledge on using the developer tools can read your debug messages. Depending on what you are logging, this may not be a desirable behavior.

One of the best approach is to wrap the console.log in one your methods, and where you can check for conditions and execute it. In production build, you can avoid having these functions. This SO question talks in details about how to do the same using Closure compiler.

So, answer your questions.

  1. Yes it will reduce the speed negligible.
  2. But, don't have it as its too easy for a person to read your logs.
  3. The answers to this question may give you hints on how to remove them from production.