diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-10-04 13:17:25 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-10-04 13:17:25 +0300 |
commit | f2348dd98baeb7dc3e0542465ede897c15d7cbc9 (patch) | |
tree | 8a14ff70c67377e34c38598d93c377fcdb0ef484 /README.md | |
parent | 253c7c23258e9c783459f683a385bb518f18403a (diff) | |
download | tracifyjs-f2348dd98baeb7dc3e0542465ede897c15d7cbc9.tar.gz tracifyjs-f2348dd98baeb7dc3e0542465ede897c15d7cbc9.zip |
Rename clean_getters to pure_getters; add pure_funcs.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -184,38 +184,67 @@ you can pass a comma-separated list of options. Options are in the form to set `true`; it's effectively a shortcut for `foo=true`). - `sequences` -- join consecutive simple statements using the comma operator + - `properties` -- rewrite property access using the dot notation, for example `foo["bar"] → foo.bar` + - `dead_code` -- remove unreachable code + - `drop_debugger` -- remove `debugger;` statements + - `unsafe` (default: false) -- apply "unsafe" transformations (discussion below) + - `conditionals` -- apply optimizations for `if`-s and conditional expressions + - `comparisons` -- apply certain optimizations to binary nodes, for example: `!(a <= b) → a > b` (only when `unsafe`), attempts to negate binary nodes, e.g. `a = !b && !c && !d && !e → a=!(b||c||d||e)` etc. + - `evaluate` -- attempt to evaluate constant expressions + - `booleans` -- various optimizations for boolean context, for example `!!a ? b : c → a ? b : c` + - `loops` -- optimizations for `do`, `while` and `for` loops when we can statically determine the condition + - `unused` -- drop unreferenced functions and variables + - `hoist_funs` -- hoist function declarations + - `hoist_vars` (default: false) -- hoist `var` declarations (this is `false` by default because it seems to increase the size of the output in general) + - `if_return` -- optimizations for if/return and if/continue + - `join_vars` -- join consecutive `var` statements + - `cascade` -- small optimization for sequences, transform `x, x` into `x` and `x = something(), x` into `x = something()` + - `warnings` -- display warnings when dropping unreachable code or unused declarations etc. + - `negate_iife` -- negate "Immediately-Called Function Expressions" where the return value is discarded, to avoid the parens that the code generator would insert. -- `clean_getters` -- the default is `false`. If you pass `true` for + +- `pure_getters` -- the default is `false`. If you pass `true` for this, UglifyJS will assume that object property access (e.g. `foo.bar` or `foo["bar"]`) doesn't have any side effects. +- `pure_funcs` -- default `null`. You can pass an array of names and + UglifyJS will assume that those functions do not produce side + effects. DANGER: will not check if the name is redefined in scope. + An example case here, for instance `var q = Math.floor(a/b)`. If + variable `q` is not used elsewhere, UglifyJS will drop it, but will + still keep the `Math.floor(a/b)`, not knowing what it does. You can + pass `pure_funcs: [ 'Math.floor' ]` to let it know that this + function won't produce any side effect, in which case the whole + statement would get discarded. The current implementation adds some + overhead (compression will be slower). + ### The `unsafe` option It enables some transformations that *might* break code logic in certain |