- `booleans` -- various optimizations for boolean context, for example `!!a
? b : c → a ? b : c`
+- `typeofs` -- default `true`. Transforms `typeof foo == "undefined"` into
+ `foo === void 0`. Note: recommend to set this value to `false` for IE10 and
+ earlier versions due to known issues.
+
- `loops` -- optimizations for `do`, `while` and `for` loops when we can
statically determine the condition
- `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)
```
To enable fast minify mode with the API use:
```js
-UglifyJS.minify(code, { compress: false, mangle: true });
+UglifyJS.minify(code, { compress: false, mangle: true });
```
switches : !false_by_default,
top_retain : null,
toplevel : !!(options && options["top_retain"]),
+ typeofs : !false_by_default,
unsafe : false,
unsafe_comps : false,
unsafe_Func : false,
case "==":
case "!=":
// "undefined" == typeof x => undefined === x
- if (self.left instanceof AST_String
+ if (compressor.option("typeofs")
+ && self.left instanceof AST_String
&& self.left.value == "undefined"
&& self.right instanceof AST_UnaryPrefix
&& self.right.operator == "typeof") {
typeof_eq_undefined: {
options = {
- comparisons: true
+ comparisons: true,
+ typeofs: true,
}
input: {
var a = typeof b != "undefined";
options = {
comparisons: true,
ie8: true,
+ typeofs: true,
}
input: {
var a = typeof b != "undefined";
undefined_redefined: {
options = {
- comparisons: true
+ comparisons: true,
+ typeofs: true,
}
input: {
function f(undefined) {
undefined_redefined_mangle: {
options = {
- comparisons: true
+ comparisons: true,
+ typeofs: true,
}
mangle = {}
input: {