Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UglifyJS options to only remove dead code

Is there a way to call the UglifyJS2 API in a node script (ie by calling require('uglify-js').minify) on a string of code such that it removes dead/unreachable code but does not apply any compression

For example:

var foo = 'bar';
if (false) {
    foo = 'yo';
}
alert('Foo value found');
alert(foo);

Would become

var foo = 'bar';
alert('Foo value found');
alert(foo);
like image 455
JoeR Avatar asked Dec 18 '15 17:12

JoeR


1 Answers

Very late answer, but compress: {defaults: false, dead_code: true, unused: true} will work in Terser. See docs.

like image 152
dmnd Avatar answered Oct 06 '22 20:10

dmnd