Skip to content

Releases: tdewolff/minify

v2.9.2

31 Aug 16:47
Compare
Choose a tag to compare
  • JS: only put var declaration into for or while, and not let nor const, fixes #325
  • JS: merge more efficiently a var declaration with a for or while statement

v2.9.1

29 Aug 22:54
Compare
Choose a tag to compare
  • JS: fix parsing in identifier in group expressions
  • JS: fix parsing identifiers inside arrow function body in some cases #324
  • JS: keep all license comments at the top of the file
  • JS: minify typeof x==='undefined' to typeof x=='undefined'
  • JS: merge expressions and var declarations with for with empty initializer or with while statement converted to for
  • JS: iteratively merge if(a){return b}if(c){return d}return e chains to return a?b:c?d:e

v2.9.0

26 Aug 14:12
3630c79
Compare
Choose a tag to compare
  • 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

v2.8.0

28 Jul 23:23
Compare
Choose a tag to compare

WARNING for package maintainers, some files have been renamed, adjust your build scripts accordingly.

  • Use Makefile instead of GoReleaser to build releases for all architectures, use make release. This fixes the README.md file location inside the archives to be in the root of the archive
  • Release archives will no longer have the version name explicitly stated, fixes #316
  • Remove cmd/minify/install.sh, use make install instead
  • Rename cmd/minify/minify_bash_tab_completion to cmd/minify/bash_completion
  • Rename LICENSE.md to LICENSE as it is not a Markdown file
  • Rename min subpackage to minify
  • cmd: running minify without arguments will print a more informative error message
  • cmd: bad arguments will not display cmd usage automatically

v2.7.7

24 Jul 16:59
Compare
Choose a tag to compare
  • cmd: fix file paths on Windows when input and output directories are equal (slash vs backslash)
  • cmd: add --cpuprofile and --memprofile options
  • cmd: fix usage of --match and --sync simultaneously, fixes #315
  • cmd: --match applies to all filename inputs not just under directories
  • CSS: remove whitespace around custom variable value, fixes #305
  • JSON: minify numbers, fixes #302
  • HTML: fix slow parsing of <a> tag with many name or id attributes (OSS-Fuzz)
  • Don't replace space by + in DataURI, fixes #314
  • Don't escape @ : ; = ? + , / $ \t \n \r in DataURIs (works for Chrome, Firefox, Opera, Edge, Safari, Yandex, and IE9, IE10, IE11)

v2.7.6

08 Jun 17:54
Compare
Choose a tag to compare
  • HTML: remove text and whitespace within select and optgroup tags
  • CSS: fix slow parsing of selectors when they contain many errors (OSS-Fuzz)
  • CSS: fix RGB/HSL when a parameter overflows (OSS-Fuzz)
  • CSS: fix slow parsing of large HSL parameters (OSS-Fuzz)
  • cmd: properly run defer calls after command ends, may fix some race bugs
  • Add easy API in the min/ subpackage
  • Add project to OSS-Fuzz

v2.7.4

24 Apr 20:07
Compare
Choose a tag to compare
  • CSS: fix minification of flex, default of flex-basis is zero for three value case, fixes #292
  • CSS: remove whitespace within @import url(...), fixes #296
  • HTML: remove spaces around/in picture and audio following whitespace removal rules for phrasing elements

v2.7.3

12 Mar 13:02
Compare
Choose a tag to compare
  • external minifiers can now use input/output files instead of only stdin/stdout using the $in and $out keywords
  • SVG: don't minify inside foreignObject, fixes #291

v2.7.2

14 Jan 15:29
Compare
Choose a tag to compare
  • SVG: bugfix for C, S, Q, and T commands where if the control points would not overlap with the start or end points of the curve, it would still be converted to a line.

v2.7.1

13 Jan 20:35
Compare
Choose a tag to compare
  • DataURI: if the original data URI is shorter than the URL-encoded/base64-encoded URI, use the original instead, fixes #282
  • Bugfix: decimal (i.e. without exponentials) incorrectly minified 139.9 to 230 instead of 140