From f3a487a36829eabc7b2d878eba299f7d97d830e0 Mon Sep 17 00:00:00 2001 From: kzc Date: Sun, 2 Jul 2017 13:37:04 -0400 Subject: [PATCH] document fast mangle-only minify mode (#2194) --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index c277f653..671d7136 100644 --- a/README.md +++ b/README.md @@ -1026,3 +1026,29 @@ in total it's a bit more than just using UglifyJS's own parser. [acorn]: https://github.com/ternjs/acorn [sm-spec]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k + +### Uglify Fast Minify Mode + +It's not well known, but variable and function name mangling accounts for +95% of the size reduction in minified code for most javascript - not +elaborate code transforms. One can simply disable `compress` to speed up +Uglify builds by 3 to 4 times. In this fast `mangle`-only mode Uglify has +comparable minify speeds and gzip sizes to +[`butternut`](https://www.npmjs.com/package/butternut): + +| d3.js | minify size | gzip size | minify time (seconds) | +| --- | ---: | ---: | ---: | +| original | 451,131 | 108,733 | - | +| uglify-js@3.0.23 mangle=false, compress=false | 316,600 | 85,245 | 0.73 | +| uglify-js@3.0.23 mangle=true, compress=false | 220,216 | 72,730 | 1.21 | +| Butternut 0.4.6 | 217,568 | 72,738 | 1.81 | +| uglify-js@3.0.23 mangle=true, compress=true | 212,511 | 71,560 | 4.64 | + +To enable fast minify mode from the CLI use: +``` +uglifyjs file.js -m +``` +To enable fast minify mode with the API use: +```js +UglifyJS.minify(code, { compress: false, mangle: true }); +``` -- 2.34.1