Lines Matching +full:fail +full:- +full:fast

7 - `uglify-js` supports JavaScript and most language features in ECMAScript.
8 - For more exotic parts of ECMAScript, process your source file with transpilers
9 like [Babel](https://babeljs.io/) before passing onto `uglify-js`.
10 - `uglify-js@3` has a simplified [API](#api-reference) and [CLI](#command-line-usage)
11 …that is not backwards compatible with [`uglify-js@2`](https://github.com/mishoo/UglifyJS/tree/v2.x…
14 -------
21 npm install uglify-js -g
25 npm install uglify-js
42 uglifyjs --compress --mangle -- input.js
47 -h, --help Print usage information.
48 `--help options` for details on available options.
49 -V, --version Print version number.
50 -p, --parse <options> Specify parser options:
59 -c, --compress [options] Enable compressor/specify compressor options:
63 -m, --mangle [options] Mangle names/specify mangler options:
65 --mangle-props [options] Mangle properties/specify mangler options:
74 -b, --beautify [options] Beautify output/specify output options:
75 `beautify` Enabled with `--beautify` by default.
82 0 - auto
83 1 - single
84 2 - double
85 3 - original
89 -O, --output-opts [options] Specify output options (`beautify` disabled by default).
90 -o, --output <file> Output file path (default STDOUT). Specify `ast` or
93 --annotations Process and preserve comment annotations.
95 --no-annotations Ignore and discard comment annotations.
96 --comments [filter] Preserve copyright comments in the output. By
98 JSDoc-style comments that contain "@license" or
101 - "all" to keep all comments
102 - a valid JS RegExp like `/foo/` or `/^!/` to
108 --config-file <file> Read `minify()` options from JSON file.
109 -d, --define <expr>[=value] Global definitions.
110 -e, --enclose [arg[:value]] Embed everything in a big function, with configurable
112 --expression Parse a single expression, rather than a program
114 --ie Support non-standard Internet Explorer.
117 By default UglifyJS will not try to be IE-proof.
118 --keep-fargs Do not mangle/drop function arguments.
119 --keep-fnames Do not mangle/drop function names. Useful for
121 --module Process input as ES module (implies --toplevel)
122 --name-cache <file> File to hold mangled name mappings.
123 --self Build UglifyJS as a library (implies --wrap UglifyJS)
124 --source-map [options] Enable source map/specify source map options:
140 --timings Display operations run time on STDERR.
141 --toplevel Compress and/or mangle variables in top level scope.
142 --v8 Support non-standard Chrome & Node.js
145 By default UglifyJS will not try to be v8-proof.
146 --verbose Print diagnostic messages.
147 --warn Print warning messages.
148 --webkit Support non-standard Safari/Webkit.
151 By default UglifyJS will not try to be Safari-proof.
152 --wrap <name> Embed everything in a big function, making the
159 Specify `--output` (`-o`) to declare the output file. Otherwise the output
166 `--source-map --output output.js` (source map will be written out to
171 - `--source-map "filename='<NAME>'"` to specify the name of the source map. The value of
172 `filename` is only used to set `file` attribute (see [the spec][sm-spec])
175 - `--source-map "root='<URL>'"` to pass the URL where the original files can be found.
177 - `--source-map "names=false"` to omit symbol names if you want to reduce size
180 - `--source-map "url='<URL>'"` to specify the URL where the source map can be found.
181 Otherwise UglifyJS assumes HTTP `X-SourceMap` is being used and will omit the
187 -o foo.min.js -c -m \
188 --source-map "root='http://foo.com/src',url='foo.min.js.map'"
207 To use this feature pass `--source-map "content='/path/to/input/source.map'"`
208 or `--source-map "content=inline"` if the source map is included inline with
213 You need to pass `--compress` (`-c`) to enable the compressor. Optionally
214 you can pass a comma-separated list of [compress options](#compress-options).
222 uglifyjs file.js -c toplevel,sequences=false
226 To enable the mangler you need to pass `--mangle` (`-m`). The following
227 (comma-separated) options are supported:
229 - `eval` (default: `false`) — mangle names visible in scopes where `eval` or
232 - `reserved` (default: `[]`) — when mangling is enabled but you want to
234 `--mangle reserved` — pass a comma-separated list of names. For example:
236 uglifyjs ... -m reserved=['$','require','exports']
240 ### CLI mangling property names (`--mangle-props`)
244 `--mangle-props` to enable it. It will mangle all properties in the
263 $ uglifyjs example.js -c -m --mangle-props
270 $ uglifyjs example.js -c -m --mangle-props reserved=[foo_,bar_]
277 $ uglifyjs example.js -c -m --mangle-props regex=/_$/
285 $ uglifyjs example.js -c -m --mangle-props regex=/_$/,reserved=[bar_]
292 default (`--mangle-props builtins` to override).
296 `--mangle-props domprops` to disable this feature.
299 mangled. For example, `--mangle-props regex=/^_/` will only mangle property
304 mangled to the same name in all of them. For this, pass `--name-cache filename.json`
309 $ rm -f /tmp/cache.json # start fresh
310 $ uglifyjs file1.js file2.js --mangle-props --name-cache /tmp/cache.json -o part1.js
311 $ uglifyjs file3.js file4.js --mangle-props --name-cache /tmp/cache.json -o part2.js
320 ### Mangling unquoted names (`--mangle-props keep_quoted`)
336 $ uglifyjs stuff.js --mangle-props keep_quoted -c -m
346 $ uglifyjs stuff.js --mangle-props keep_quoted -c -m -O keep_quoted_props
354 You can also pass `--mangle-props debug` in order to mangle property names
361 $ uglifyjs stuff.js --mangle-props debug -c -m
367 You can also pass a custom suffix using `--mangle-props debug=XYZ`. This would then
380 var UglifyJS = require("uglify-js");
384 which will perform all minification [phases](#minify-options) in a configurable
385 manner. By default `minify()` will enable the options [`compress`](#compress-options)
386 and [`mangle`](#mangle-options). Example:
500 Note: unlike `uglify-js@2.x`, the `3.x` API does not throw errors. To
509 - `annotations` — pass `false` to ignore all comment annotations and elide them
514 - `compress` (default: `{}`) — pass `false` to skip compressing entirely.
515 Pass an object to specify custom [compress options](#compress-options).
517 - `expression` (default: `false`) — parse as a single expression, e.g. JSON.
519 - `ie` (default: `false`) — enable workarounds for Internet Explorer bugs.
521 - `keep_fargs` (default: `false`) — pass `true` to prevent discarding or mangling
524 - `keep_fnames` (default: `false`) — pass `true` to prevent discarding or mangling
527 - `mangle` (default: `true`) — pass `false` to skip mangling names, or pass
528 an object to specify [mangle options](#mangle-options) (see below).
530 - `mangle.properties` (default: `false`) — a subcategory of the mangle option.
531 Pass an object to specify custom [mangle property options](#mangle-properties-options).
533 - `module` (default: `false`) — set to `true` if you wish to process input as
534 ES module, i.e. implicit `"use strict";` and support for top-level `await`,
537 - `nameCache` (default: `null`) — pass an empty object `{}` or a previously
544 - `output` (default: `null`) — pass an object if you wish to specify
545 additional [output options](#output-options). The defaults are optimized
548 - `parse` (default: `{}`) — pass an object if you wish to specify some
549 additional [parse options](#parse-options).
551 - `sourceMap` (default: `false`) — pass an object if you wish to specify
552 [source map options](#source-map-options).
554 - `toplevel` (default: `false`) — set to `true` if you wish to enable top level
557 - `v8` (default: `false`) — enable workarounds for Chrome & Node.js bugs.
559 - `warnings` (default: `false`) — pass `true` to return compressor warnings
562 - `webkit` (default: `false`) — enable workarounds for Safari/WebKit bugs.
611 `filename` is only used to set `file` attribute (see [the spec][sm-spec])
639 If you're using the `X-SourceMap` header instead, you can just omit `sourceMap.url`.
646 - `bare_returns` (default: `false`) — support top level `return` statements
648 - `html5_comments` (default: `true`) — process HTML comment as workaround for
651 - `module` (default: `false`) — set to `true` if you wish to process input as
652 ES module, i.e. implicit `"use strict";` and support for top-level `await`.
654 - `shebang` (default: `true`) — support `#!command` as the first line
658 - `annotations` (default: `true`) — Pass `false` to disable potentially dropping
663 - `arguments` (default: `true`) — replace `arguments[index]` with function
666 - `arrows` (default: `true`) — apply optimizations to arrow functions
668 - `assignments` (default: `true`) — apply optimizations to assignment expressions
670 - `awaits` (default: `true`) — apply optimizations to `await` expressions
672 - `booleans` (default: `true`) — various optimizations for boolean context,
675 - `collapse_vars` (default: `true`) — Collapse single-use non-constant variables,
678 - `comparisons` (default: `true`) — apply certain optimizations to binary nodes,
682 - `conditionals` (default: `true`) — apply optimizations for `if`-s and conditional
685 - `dead_code` (default: `true`) — remove unreachable code
687 - `default_values` (default: `true`) — drop overshadowed default values
689 - `directives` (default: `true`) — remove redundant or non-standard directives
691 - `drop_console` (default: `false`) — Pass `true` to discard calls to
696 - `drop_debugger` (default: `true`) — remove `debugger;` statements
698 - `evaluate` (default: `true`) — Evaluate expression for shorter constant
703 - `expression` (default: `false`) — Pass `true` to preserve completion values
706 - `functions` (default: `true`) — convert declarations from `var` to `function`
709 - `global_defs` (default: `{}`) — see [conditional compilation](#conditional-compilation)
711 - `hoist_exports` (default: `true`) — hoist `export` statements to facilitate
714 - `hoist_funs` (default: `false`) — hoist function declarations
716 - `hoist_props` (default: `true`) — hoist properties from constant object and
722 - `hoist_vars` (default: `false`) — hoist `var` declarations (this is `false`
725 - `if_return` (default: `true`) — optimizations for if/return and if/continue
727 - `imports` (default: `true`) — drop unreferenced import symbols when used with `unused`
729 - `inline` (default: `true`) — inline calls to function with simple/`return` statement:
730 - `false` — same as `0`
731 - `0` — disabled inlining
732 - `1` — inline simple functions
733 - `2` — inline functions with arguments
734 - `3` — inline functions with arguments and variables
735 - `4` — inline functions with arguments, variables and statements
736 - `true` — same as `4`
738 - `join_vars` (default: `true`) — join consecutive `var` statements
740 - `keep_fargs` (default: `false`) — discard unused function arguments except
744 - `keep_infinity` (default: `false`) — Pass `true` to prevent `Infinity` from
747 - `loops` (default: `true`) — optimizations for `do`, `while` and `for` loops
750 - `merge_vars` (default: `true`) — combine and reuse variables.
752 - `module` (default: `false`) — set to `true` if you wish to process input as
755 - `negate_iife` (default: `true`) — negate "Immediately-Called Function Expressions"
759 - `objects` (default: `true`) — compact duplicate keys in object literals.
761 - `passes` (default: `1`) — The maximum number of times to run compress.
765 - `properties` (default: `true`) — rewrite property access using the dot notation, for
768 - `pure_funcs` (default: `null`) — You can pass an array of names and
780 - `pure_getters` (default: `"strict"`) — If you pass `true` for
783 Specify `"strict"` to treat `foo.bar` as side-effect-free only when
786 - `reduce_funcs` (default: `true`) — Allows single-use functions to be
792 - `reduce_vars` (default: `true`) — Improve optimization on variables assigned with and
795 - `rests` (default: `true`) — apply optimizations to rest parameters
797 - `sequences` (default: `true`) — join consecutive simple statements using the
806 - `side_effects` (default: `true`) — drop extraneous code which does not affect
809 - `spreads` (default: `true`) — flatten spread expressions.
811 - `strings` (default: `true`) — compact string concatenations.
813 - `switches` (default: `true`) — de-duplicate and remove unreachable `switch` branches
815 - `templates` (default: `true`) — compact template literals by embedding expressions
818 - `top_retain` (default: `null`) — prevent specific toplevel functions and
819 variables from `unused` removal (can be array, comma-separated, RegExp or
822 - `toplevel` (default: `false`) — drop unreferenced functions (`"funcs"`) and/or
826 - `typeofs` (default: `true`) — compress `typeof` expressions, e.g.
829 - `unsafe` (default: `false`) — apply "unsafe" transformations (discussion below)
831 - `unsafe_comps` (default: `false`) — assume operands cannot be (coerced to) `NaN`
835 - `unsafe_Function` (default: `false`) — compress and mangle `Function(args, code)`
838 - `unsafe_math` (default: `false`) — optimize numerical expressions like
841 - `unsafe_proto` (default: `false`) — optimize expressions like
844 - `unsafe_regexp` (default: `false`) — enable substitutions of variables with
847 - `unsafe_undefined` (default: `false`) — substitute `void 0` if there is a
851 - `unused` (default: `true`) — drop unreferenced functions and variables (simple
854 - `varify` (default: `true`) — convert block-scoped declarations into `var`
857 - `yields` (default: `true`) — apply optimizations to `yield` expressions
861 - `eval` (default: `false`) — Pass `true` to mangle names visible in scopes
864 - `reserved` (default: `[]`) — Pass an array of identifiers that should be
867 - `toplevel` (default: `false`) — Pass `true` to mangle names declared in the
894 - `builtins` (default: `false`) — Use `true` to allow the mangling of built-in
897 - `debug` (default: `false`) — Mangle names with the original name still present.
898 Pass an empty string `""` to enable, or a non-empty string to set the debug suffix.
900 - `domprops` (default: `false`) — Use `true` to allow the mangling of properties
903 - `keep_fargs` (default: `false`) — Use `true` to prevent mangling of function
906 - `keep_quoted` (default: `false`) — Only mangle unquoted property names.
908 - `regex` (default: `null`) — Pass a RegExp literal to only mangle property
911 - `reserved` (default: `[]`) — Do not mangle property names listed in the
917 case you want beautified output, pass `--beautify` (`-b`). Optionally you
920 - `annotations` (default: `false`) — pass `true` to retain comment annotations
924 - `ascii_only` (default: `false`) — escape Unicode characters in strings and
925 regexps (affects directives with non-ascii characters becoming invalid)
927 - `beautify` (default: `true`) — whether to actually beautify the output.
928 Passing `-b` will set this to true, but you might need to pass `-b` even
930 arguments, so you can use `-b beautify=false` to override it.
932 - `braces` (default: `false`) — always insert braces in `if`, `for`,
936 - `comments` (default: `false`) — pass `true` or `"all"` to preserve all
937 comments, `"some"` to preserve multi-line comments that contain `@cc_on`,
938 `@license`, or `@preserve` (case-insensitive), a regular expression string
946 - `extendscript` (default: `false`) — enable workarounds for Adobe ExtendScript
949 - `galio` (default: `false`) — enable workarounds for ANT Galio bugs
951 - `indent_level` (default: `4`) — indent by specified number of spaces or the
954 - `indent_start` (default: `0`) — prefix all lines by whitespace sequence
957 - `inline_script` (default: `true`) — escape HTML comments and the slash in
960 - `keep_quoted_props` (default: `false`) — when turned on, prevents stripping
963 - `max_line_len` (default: `false`) — maximum line length (for uglified code)
965 - `preamble` (default: `null`) — when passed it must be a string and
970 - `preserve_line` (default: `false`) — pass `true` to retain line numbering on
973 - `quote_keys` (default: `false`) — pass `true` to quote all keys in literal
976 - `quote_style` (default: `0`) — preferred quote style for strings (affects
978 - `0` — prefers double quotes, switches to single quotes when there are
980 - `1` — always use single quotes
981 - `2` — always use double quotes
982 - `3` — always use the original quotes
984 - `semicolons` (default: `true`) — separate statements with semicolons. If
989 - `shebang` (default: `true`) — preserve shebang `#!` in preamble (bash scripts)
991 - `width` (default: `80`) — only takes effect when beautification is on, this
997 - `wrap_iife` (default: `false`) — pass `true` to wrap immediately invoked
1005 You can pass `--comments` to retain certain comments in the output. By
1006 default it will keep JSDoc-style comments that contain "@preserve",
1008 `--comments all` to keep all the comments, or a valid JavaScript regexp to
1009 keep only comments that match this regexp. For example `--comments /^!/`
1038 - `new Array(1, 2, 3)` or `Array(1, 2, 3)` → `[ 1, 2, 3 ]`
1039 - `new Object()` → `{}`
1040 - `String(exp)` or `exp.toString()` → `"" + exp`
1041 - `new Object/RegExp/Function/Error/Array (...)` → we discard the `new`
1045 You can use the `--define` (`-d`) switch in order to declare global
1047 scope). For example if you pass `--define DEBUG=false` then, coupled with
1055 You can specify nested constants in the form of `--define env.DEBUG=false`.
1072 uglifyjs build/defines.js js/foo.js js/bar.js... -c
1096 To replace an identifier with an arbitrary non-constant expression it is
1132 code: false // optional - faster if false
1147 code: true // optional - faster if false
1165 [practical reasons](http://lisperator.net/blog/uglifyjs-why-not-switching-to-spidermonkey-ast/)
1169 For example [Acorn][acorn] is a super-fast parser that produces a
1174 acorn file.js | uglifyjs -p spidermonkey -m -c
1176 The `-p spidermonkey` option tells UglifyJS that all input files are not
1183 More for fun, I added the `-p acorn` option which will use Acorn to do all
1186 Acorn is really fast (e.g. 250ms instead of 380ms on some 650K code), but
1191 [sm-spec]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k
1193 ### Uglify Fast Minify Mode
1196 for 95% of the size reduction in minified code for most JavaScript - not
1201 | --- | ---: | ---: | ---: |
1202 | original | 511,371 | 119,932 | - |
1203 | uglify-js@3.13.0 mangle=false, compress=false | 363,988 | 95,695 | 0.56 |
1204 | uglify-js@3.13.0 mangle=true, compress=false | 253,305 | 81,281 | 0.99 |
1205 | uglify-js@3.13.0 mangle=true, compress=true | 244,436 | 79,854 | 5.30 |
1207 To enable fast minify mode from the CLI use:
1209 uglifyjs file.js -m
1211 To enable fast minify mode with the API use:
1228 - The code does not rely on preserving its runtime performance characteristics.
1231 see [`reduce_funcs`](#compress-options).
1232 - `.toString()` and `.valueOf()` don't have side effects, and for built-in
1234 - `undefined`, `NaN` and `Infinity` have not been externally redefined.
1235 - `arguments.callee`, `arguments.caller` and `Function.prototype.caller` are not used.
1236 - The code doesn't expect the contents of `Function.prototype.toString()` or
1238 - Getting and setting properties on a plain object does not cause other side effects
1240 - Object properties can be added, removed and modified (not prevented with
1243 - If array destructuring is present, index-like properties in `Array.prototype`
1254 - Earlier versions of JavaScript will throw `SyntaxError` with the following:
1264 - Iteration order of keys over an object which contains spread syntax in later
1266 - When `toplevel` is enabled, UglifyJS effectively assumes input code is wrapped
1269 A = "FAIL";
1270 var B = "FAIL";
1278 // "FAIL" after compress and/or mangle
1282 - Use of `arguments` alongside destructuring as function parameters, e.g.
1284 of Chrome and Node.js - UglifyJS may modify the input which in turn may
1286 - Earlier versions of Chrome and Node.js will throw `ReferenceError` with the
1300 - Later versions of JavaScript will throw `SyntaxError` with the following:
1308 - Later versions of JavaScript will throw `SyntaxError` with the following:
1318 - Some versions of Chrome and Node.js will throw `ReferenceError` with the
1327 - Some arithmetic operations with `BigInt` may throw `TypeError`:
1333 - Some versions of JavaScript will throw `SyntaxError` with the
1340 - Some versions of JavaScript will throw `SyntaxError` with the
1349 - Some versions of Chrome and Node.js will give incorrect results with the
1362 - Later versions of JavaScript will throw `SyntaxError` with the following:
1371 - Later versions of JavaScript will throw `SyntaxError` with the following:
1375 // SyntaxError: The left-hand side of a for-of loop may not be 'async'.
1378 - Some versions of Chrome and Node.js will give incorrect results with the
1384 return "FAIL";
1390 return "FAIL";
1395 // Actual: "PASS FAIL"
1398 - Earlier versions of JavaScript will throw `TypeError` with the following:
1411 - Later versions of Chrome and Node.js will give incorrect results with the
1421 console.log("FAIL");
1424 // Actual: "FAIL"
1427 - Some versions of Chrome and Node.js will give incorrect results with the
1440 - Later versions of Chrome and Node.js will give incorrect results with the
1455 - Later versions of JavaScript will throw `SyntaxError` with the following:
1465 - Adobe ExtendScript will give incorrect results with the following:
1467 alert(true ? "PASS" : false ? "FAIL" : null);
1469 // Actual: "FAIL"
1472 - Adobe ExtendScript will give incorrect results with the following:
1474 alert(42 ? null ? "FAIL" : "PASS" : "FAIL");