on your own code, it should reduce the minified size. Here's what happens
when this flag is on:
-- `new Array(1, 2, 3)` or `Array(1, 2, 3)` → `[1, 2, 3 ]`
+- `new Array(1, 2, 3)` or `Array(1, 2, 3)` → `[ 1, 2, 3 ]`
- `new Object()` → `{}`
- `String(exp)` or `exp.toString()` → `"" + exp`
- `new Object/RegExp/Function/Error/Array (...)` → we discard the `new`
- `typeof foo == "undefined"` → `foo === void 0`
- `void 0` → `undefined` (if there is a variable named "undefined" in
scope; we do it because the variable name will be mangled, typically
- reduced to a single character).
+ reduced to a single character)
+- discards unused function arguments (affects `function.length`)
### Conditional compilation
var tt = new TreeTransformer(
function before(node, descend, in_list) {
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
- if (!compressor.option("keep_fargs")) {
+ if (compressor.option("unsafe") && !compressor.option("keep_fargs")) {
for (var a = node.argnames, i = a.length; --i >= 0;) {
var sym = a[i];
if (sym.unreferenced()) {
unused_funarg_1: {
- options = { unused: true };
+ options = { unused: true, unsafe: true };
input: {
function f(a, b, c, d, e) {
return a + b;
}
unused_funarg_2: {
- options = { unused: true };
+ options = { unused: true, unsafe: true };
input: {
function f(a, b, c, d, e) {
return a + c;
}
keep_fnames: {
- options = { unused: true, keep_fnames: true };
+ options = { unused: true, keep_fnames: true, unsafe: true };
input: {
function foo() {
return function bar(baz) {};
return function bar() {};
}
}
-}
\ No newline at end of file
+}