Will console.log reduce JavaScript execution performance?

前端 未结 9 1265
半阙折子戏
半阙折子戏 2020-12-24 00:03

Will use of the debugging feature console.log reduce JavaScript execution performance? Will it affect the speed of script execution in production environments?

9条回答
  •  情深已故
    2020-12-24 00:50

    Will use of the debugging feature console.log reduce JavaScript execution performance? Will it affect the speed of script execution in production environments?

    Of course, console.log() will reduce your program's performance since it takes computational time.

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

    Put this code at the beginning of your script to override the standard console.log function to an empty function.

    console.log = function () { };
    

提交回复
热议问题