Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  18] [ 6]  / answers: 1 / hits: 68055  / 12 Years ago, wed, july 11, 2012, 12:00:00

Will use of the debugging feature console.log 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 configuration location?


More From » performance

 Answers
58

If you are going to have this on a public site or something, anyone 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 approaches is to wrap the console.log in one of your methods, and where you can check for conditions and execute it. In a production build, you can avoid having these functions. This Stack Overflow question talks in details about how to do the same using the Closure compiler.



So, to answer your questions:




  1. Yes, it will reduce the speed, though only negligibly.

  2. But, don't use it as it's 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.


[#84342] Monday, July 9, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
siena

Total Points: 199
Total Questions: 91
Total Answers: 91

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;