Rich-Harris / butternut

The fast, future-friendly minifier
https://butternut.now.sh
MIT License
1.17k stars 17 forks source link

Better mangling #141

Closed Rich-Harris closed 7 years ago

Rich-Harris commented 7 years ago

This implements most of #110 — rather than mangling variables as a, b, c etc, the most common characters are used first. This results in slightly better gzip compression. As of this PR, Butternut more consistently generates smaller zipped output than Uglify in mangle-only mode. (Full credit for the idea belongs to Uglify.)

There's a little more we can do, e.g. sorting declarations by number of instances, but the hard part is done now.

(Edit: turns out sorting declarations by number of instances makes it worse. Man, gzip is a mysterious beast.)