2 ms·
Uglify has actually gotten better the last few years, but Closure is still faster on multi-core machines. Here's on one of our apps: $ wc -c index.js | gre
by lobster_johnson 10y ago
Uglify has actually gotten better the last few years, but Closure is still faster on multi-core machines. Here's on one of our apps:
$ wc -c index.js | grep -v total
9320511 index.js
$ cat index.js | time closure-compiler \
--warning_level quiet \
--third_party \
--jscomp_off es3 \
--compilation_level SIMPLE_OPTIMIZATIONS \
--language_in ECMASCRIPT5 > index.js.closure 2>/dev/null
33.54s user 0.93s system 369% cpu 9.336 total
$ cat index.js | time closure-compiler \
--warning_level quiet \
--third_party \
--jscomp_off es3 \
--compilation_level ADVANCED_OPTIMIZATIONS \
--language_in ECMASCRIPT5 > index.js.closure-advanced 2>/dev/null
33.54s user 0.93s system 369% cpu 9.336 total
$ cat index.js | time node_modules/.bin/uglifyjs \
--screw-ie8 --mangle --compress - > index.js.uglify 2>/dev/null
18.88s user 0.24s system 103% cpu 18.475 total
$ wc -c index.js.*. | grep -v total
1750478 index.js.closure
1515331 index.js.closure-advanced
1763350 index.js.uglify
$ gzip -9 index.js.*
$ wc -c index.js*.gz | grep -v total
369749 index.js.closure-advanced.gz
397468 index.js.closure.gz
387896 index.js.uglify.gz
(Closure 20170218 on Oracle Java 8, uglify-js 2.4.19 on Node 6.8.1, running on MBP Pro 2015).
It's worth noting that Closure is heavily parallelized, and uses 50% of the time to complete by using all 4 cores at almost 100%. If you only have one core, though, Closure will be much slower.
Our apps don't use any of Google's conventions, but Closure is still able to minify as well than Uglify. I don't know if there are any specific Closure or Uglify options that could make a bigger difference.
Also worth noting that we only minify for staging/production, not during development, which would incur too much of a performance hit.
We've always used Closure, and been very happy with it.
- abritinthebay 10y agoExact inverse of my situation- CC is 3-4x slower on our codebase.