19
README.md
19
README.md
@@ -141,12 +141,19 @@ input files from the command line.
|
|||||||
|
|
||||||
## Mangler options
|
## Mangler options
|
||||||
|
|
||||||
To enable the mangler you need to pass `--mangle` (`-m`). Optionally you
|
To enable the mangler you need to pass `--mangle` (`-m`). The following
|
||||||
can pass `-m sort=true` (we'll possibly have other flags in the future) in order
|
(comma-separated) options are supported:
|
||||||
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
|
- `sort` — to assign shorter names to most frequently used variables. This
|
||||||
(and seems to happen for other libraries I tried it on) therefore it's not
|
saves a few hundred bytes on jQuery before gzip, but the output is
|
||||||
enabled by default.
|
_bigger_ after gzip (and seems to happen for other libraries I tried it
|
||||||
|
on) therefore it's not enabled by default.
|
||||||
|
|
||||||
|
- `toplevel` — mangle names declared in the toplevel scope (disabled by
|
||||||
|
default).
|
||||||
|
|
||||||
|
- `eval` — mangle names visible in scopes where `eval` or `when` are used
|
||||||
|
(disabled by default).
|
||||||
|
|
||||||
When mangling is enabled but you want to prevent certain names from being
|
When mangling is enabled but you want to prevent certain names from being
|
||||||
mangled, you can declare those names with `--reserved` (`-r`) — pass a
|
mangled, you can declare those names with `--reserved` (`-r`) — pass a
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function SymbolDef(scope, index, orig) {
|
|||||||
|
|
||||||
SymbolDef.prototype = {
|
SymbolDef.prototype = {
|
||||||
unmangleable: function(options) {
|
unmangleable: function(options) {
|
||||||
return this.global
|
return (this.global && !(options && options.toplevel))
|
||||||
|| this.undeclared
|
|| this.undeclared
|
||||||
|| (!(options && options.eval) && (this.scope.uses_eval || this.scope.uses_with));
|
|| (!(options && options.eval) && (this.scope.uses_eval || this.scope.uses_with));
|
||||||
},
|
},
|
||||||
@@ -348,7 +348,8 @@ AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options){
|
|||||||
return defaults(options, {
|
return defaults(options, {
|
||||||
except : [],
|
except : [],
|
||||||
eval : false,
|
eval : false,
|
||||||
sort : false
|
sort : false,
|
||||||
|
toplevel : false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user