investigate Terser use for minification
See original GitHub issueIn a nutshell:
- Webpack v4 uses
uglifyjs-webpack-plugin
for minification, which is actually based onuglify-es
- We had to stop using that and instead use
babel-minify-webpack-plugin
a while ago because of minification issues #4871 babel-minify
is still marked asbeta
on the website and last had an update ~3 months agobabel-minify-webpack-plugin
has not had an update in ~10 monthsuglify-es
is now no longer maintained and was eventually forked as Terser- Webpack plans to use Terser by default in v5 (next major release, still in development): https://github.com/webpack/webpack/pull/8036 and
terser-webpack-plugin
can be used in the interim
The webpack history itself is summarized neatly in this commit https://github.com/edmorley/webpack/commit/79910c6ba5c773aa5eeb4bb31aca12d405247067
I’m opening this issue up to explore whether there are benefits to switching over to using terser
in our bundling before v5:
- speed - is there a noticeable speed up when doing
yarn build:prod
? - bundle size - is it a smaller bundle compared to
babel-minify
? how much? - features - we need sourcemaps to help with getting sensible stack traces - are they still supported?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Minification: Wrestling with Terser and Webpack - YouTube
I hit an issue where minified code in production is breaking how I save page state because it depends on consistent class names....
Read more >Reduce minified code size by property mangling | Tan Li Hau
This behavior of renaming variable name to compress JavaScript code is called Mangle. Terser has several Mangle options, that allows you to ...
Read more >Minify JavaScript Using Terser - DEV Community
Terser is a javascript compressor and mangler supporting ES6+ specification. In this tutorial, you will get to know how to use terser to...
Read more >Fixing Overly Aggressive Optimization with Terser | by Omri Lavi
It looks like TerserPlugin was minifying too aggressively, and reducing functions with 1-character-length-names to 0-character-length-names.
Read more >Using terser or alternative to minify and uglify js files
Terser did mangle your function and variable names, for more you need to use more Terser settings: github.com/terser/terser.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ran some quick tests with terser by running
yarn build: prod
:| Build time | Output Size – | – | – babel-minify | 85.36s | 43.401.373 bytes (45,9 MB) terser | 73.57s | 43.381.135 bytes (45,9 MB)
I recently switched from
Uglify
toTerser
in another project, and it has considerably shortened our build time.Thanks for the input @brendonbarreto and @j-f1.
For the moment I’d like to leave things as-is in here, and potentially revisit when Webpack 5 drops to see what benefits there might be to upgrade then (e.g. https://github.com/webpack/webpack/pull/8609).