Hmm, it's a thought. I wonder whether minification could be modified to do what you want though. For instance:
var DBG = false;
if (DBG) console.log("Debug");
console.log("Foo");
That actually works fine when minified - it goes down to:
var DBG=!1;console.log("Foo");
However when in a function, it doesn't work properly (because it thinks that the state of DBG might get changed). Object.freeze doesn't seem to work either. You could do:
(function() {
var DBG = false;
function foo() {
if (DBG) console.log("Debug");
console.log("Foo");
}
setTimeout(foo,1000);
})();
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hmm, it's a thought. I wonder whether minification could be modified to do what you want though. For instance:
That actually works fine when minified - it goes down to:
However when in a function, it doesn't work properly (because it thinks that the state of DBG might get changed).
Object.freeze
doesn't seem to work either. You could do:And that minifies down really nicely: