Bad idea to leave “console.log()” calls in your production JavaScript code?

后端 未结 11 1980
醉话见心
醉话见心 2020-12-07 08:03

I have a bunch of console.log() calls in my JavaScript.

Should I comment them out before I deploy to production?

I\'d like to just leave them th

11条回答
  •  独厮守ぢ
    2020-12-07 08:31

    If you have a deployment script, you can use it to strip out the calls to console.log (and minify the file).

    While you're at it, you can throw your JS through JSLint and log the violations for inspection (or prevent the deployment).

    This is a great example of why you want to automate your deployment. If your process allows you to publish a js file with console.logs in it, at some point you will do it.

提交回复
热议问题