mishoo/UglifyJS — Issue #321: Dummy statement should be removed.
Author: gordita
Created: 2012-02-17 07:01:53+00:00
State: open

# Assume the input JS looks like this:

if (DEBUG) {
assertNotNull = function(val) {
if (val === null) {
throw new Error('val is null');
}
};
}

function app() {
var el = document.body;
assertNotNull(el);
el.innerHTML = 'yes';
}

# And the build command looks like this:

uglifyjs -d DEBUG=false -d assertNotNull=void app.js > app.min.js;

# The we will get the output looks like this
function app(){var a=document.body;void(a),a.innerHTML="yes"};

My question is that the statement "void(a)" could be be removed safely since it does
the same job like "a", which does nothing actually.

I want to be able to define certain functions at build time so that I can safely remove
those functions that actually do nothing and have no side effect by renaming them as
"void" (well, void is not actually a name of a function).

Do you think this is a good idea?