New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to separate compress and mangle runs? #23

Closed
rtfeldman opened this Issue Dec 21, 2018 · 3 comments

Comments

2 participants
@rtfeldman
Copy link

rtfeldman commented Dec 21, 2018

At the command line, to get any benefit out of the pure_funcs flag, you have to run uglify twice: first with pure_funcs and --compress (so it inlines pure functions) and then separately execute uglify a second time with --mangle.

If you give it --compress and --mangle and pure_funcs at the same time, mangle renames the pure functions and compress no longer recognizes them (because it's looking for functions with names like A2 and F2 but that's not what their names are anymore after mangle changes them).

I don't know if doing two passes is easy to set up with webpack, but I bet if you compare this way with what https://github.com/rtfeldman/elm-spa-example/blob/master/README.md#production-build is doing, I bet you get smaller assets doing it that way!

@opvasger opvasger self-assigned this Dec 21, 2018

@opvasger opvasger added the question label Dec 21, 2018

@opvasger

This comment has been minimized.

Copy link
Owner

opvasger commented Dec 21, 2018

Hello Richard!

I don't know if doing two passes is easy to set up with webpack

The Webpack-plugin is trivial to change

to get any benefit out of the pure_funcs flag, you have to run uglify twice

I'm not using Uglify.js, but a maintained fork called Terser.js. I'm pretty sure I tested this case when I made the transition, but I will write a test in my CI setup for doing a comparison with Evans script. I'll fix it if the test fails ☀️

Can you copy/paste some terminal-output that shows the size-difference?

@opvasger

This comment has been minimized.

Copy link
Owner

opvasger commented Dec 21, 2018

for /example/withScript the difference is 40 bytes before gzip. Does this number grow significantly for whatever you're building? ☀️

@opvasger

This comment has been minimized.

Copy link
Owner

opvasger commented Jan 2, 2019

for your spa example, the difference is ~120 bytes before gzip. Based on these findings, I will close this issue ☀️

@opvasger opvasger closed this Jan 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment