minify v2.9.0 Release Notes

Release Date: 2020-08-26 // over 1 year ago
    • โž• Add JS (ECMAScript 2020) minifier
    • ๐Ÿ‘Œ Improve benchmark functions
    • ๐ŸŽ Predefine byte-slices instead of inline for performance
    • Don't check write errors to output during minification, but check at the end only
    • ๐Ÿ“œ Lexers/parser now require passing parse.Input instead of io.Reader
    • ๐Ÿ“ฆ Rename subpackage min to minify

    JS minifier overview

    ๐Ÿ”‹ Features:

    • โœ‚ remove superfluous whitespace
    • โœ‚ remove superfluous semicolons
    • shorten true, false, and undefined to !0, !1 and void 0
    • ๐Ÿ“‡ rename variables and functions to shorter names (not in global scope)
    • ๐Ÿšš move var declarations to the top of the global/function scope (if more than one)
    • collapse if/else statements to expressions
    • minify conditional expressions to simpler ones
    • ๐Ÿ”€ merge sequential expression statements to one, including into return and throw
    • โœ‚ remove superfluous grouping in expressions
    • ๐Ÿšš shorten or remove string escapes
    • convert object key or index expression from string to identifier or decimal
    • ๐Ÿ”€ merge concatenated strings
    • rewrite numbers (binary, octal, decimal, hexadecimal) to shorter representations

    It compresses files at about 25 MB/s (only minifying, not considering reading/writing files) which is (much) faster than existing minifiers. Compression rate is between 1.5 and 3.0 depending on the file (respectively, the compression file size is between 35% -- 65% of the original). Example of known files:

    File Original Size Compressed Size Ratio Time Speed
    ace.js 644 kB 346 kB 53.7% 34ms 19 MB/s
    dot.js 5.2 kB 3.3 kB 64.9% 563ยตs 9.2 MB/s
    jquery.js 247 kB 85 kB 34.4% 11ms 22 MB/s
    jqueryui.js 470 kB 241 kB 51.3% 26ms 18 MB/s
    moment.js 99 kB 35 kB 34.9% 4ms 24 MB/s

    โœ… The minifier has been tested for a number of web applications including WordPress. The go-fuzz fuzzer has been used extensively in order to detect bugs, and will continue finding bugs using https://github.com/google/oss-fuzz