1

I am performing some fixes and improvements on an existing website before it goes into a production environment and I have seen a few javascript functions with the debugger statement in them, is it bad practice to keep them in the productive environment ?

Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99

3 Answers3

2

If you are talking about the actual debugger statement, yes they need to be removed. When encountered in execution they may cause the scripts to stop executing.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger

dgeare
  • 2,618
  • 5
  • 18
  • 28
  • 1
    Isn't that only while dev tools is open, though? – Kenneth K. May 22 '17 at 15:23
  • 1
    I believe it is variable based on environment. I haven't used it much myself, but IIRC I heard it will actually open the developer tools for chrome? – dgeare May 22 '17 at 15:26
  • 1
    We've been developing against Chrome (internal app) for the last year, and I have yet to observe that behavior. But point taken that it could be environment specific. – Kenneth K. May 22 '17 at 15:32
2

Yes. The debugger must be used exclusively when developing and debugging. There is literally no possible gain from leaving those statements in production.

Here are the docs in case you want to give them a look.

GMaiolo
  • 4,207
  • 1
  • 21
  • 37
1

Yes, according to linting/hinting tools debuggers should be removed as soon as you are done with them. Also, most of the time debugger/console statements are removed when you prepare your code for production deployment (uglify/minify).

See this: http://jslint.fantasy.codes/all-debugger-statements-should-be-removed

ghostCoder
  • 31
  • 6