## Mangler options
To enable the mangler you need to pass `--mangle` (`-m`). Optionally you
-can pass `-m sort` (we'll possibly have other flags in the future) in order
+can pass `-m sort=true` (we'll possibly have other flags in the future) in order
to assign shorter names to most frequently used variables. This saves a few
hundred bytes on jQuery before gzip, but the output is _bigger_ after gzip
(and seems to happen for other libraries I tried it on) therefore it's not
return defaults(options, {
except : [],
eval : false,
+ sort : false
});
});
return true; // don't descend again in TreeWalker
}
if (node instanceof AST_Scope) {
- var p = tw.parent();
+ var p = tw.parent(), a = [];
node.variables.each(function(symbol){
if (options.except.indexOf(symbol.name) < 0) {
- to_mangle.push(symbol);
+ a.push(symbol);
}
});
+ if (options.sort) a.sort(function(a, b){
+ return b.references.length - a.references.length;
+ });
+ to_mangle.push.apply(to_mangle, a);
return;
}
if (node instanceof AST_Label) {