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 ?
Asked
Active
Viewed 2,381 times
1

Mauricio Gracia Gutierrez
- 10,288
- 6
- 68
- 99
-
I don't see any value in having them there as you don't really try to debug PROD. – Razvan Dumitru May 22 '17 at 15:20
-
Yes. You will break the interwebs :P – Kenneth K. May 22 '17 at 15:20
-
Yes, why would you leave them in? – Bergi May 22 '17 at 15:20
-
1Or the interwebs will break you, as some debugger code might introduce security holes – René Jahn May 22 '17 at 15:21
-
Why would you keep it **after** debugging? JsLint and TsLint can be used to track it [check this](https://stackoverflow.com/a/20884559/427146) I usually gets a call from the lint if I miss it. – sabithpocker May 22 '17 at 15:23
-
Pros : none; Cons : it can totally break your code execution and your site. Now it's your call. – Jeremy Thille May 22 '17 at 15:24
3 Answers
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
-
1I 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
-
1We'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
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