0

I am using console.log invocations pretty extensively during development of javascript code. I wouldn't like to include these debug logs in the production code and wouldn't like to remove them permanently.

The somewhat obvious solution would be to process/filter javascript sources at the time of deployment on production server. The minimal approach would be to use grep -v console.log sample.js but it will break the code in case of multi-line or complex statements.

The javascript code is actually a template (jinja2) of javascript code but I care to keep it syntactically correct (I put templater tags in comments, strings, etc.).

Is there a smart method of doing it or I have to assume that console.log statements must be single line and the line mustn't contain other, non-debug code?

Dariusz Walczak
  • 4,848
  • 5
  • 36
  • 39
  • http://stackoverflow.com/questions/2934509/exclude-debug-javascript-code-during-minification – epascarello Sep 11 '13 at 05:25
  • Mhm. I think that I will have to give the compiler a try. I am only afraid that in case of templates it may remove significant parts of templates (either because they are comments or because they are "dead code"). – Dariusz Walczak Sep 12 '13 at 04:30

0 Answers0