Releases: tdewolff/minify
Go modules support
Add Go modules support by using the github.com/tdewolff/minify/v2
import path.
WARNING: this release may give errors for go mod
probably due to (local) caching...
Bugfixes and improved CSS minifier
Important: default mimetype for JavaScript is now application/javascript
(it used to be text/javascript
).
- HTML bugfix: keep empty
value
attribute on<input type="radio">
, because the default is not an empty string - HTML bugfix: prevent IE conditional comments from panicking in some instances
- CSS: handle
local()
for URLs - CSS: support
rgb()
andhsl()
with spaces instead of commas - CSS: improve minification for
font
,background
,background-position
,background-repeat
,background-size
,outline
andborder
declarations - CSS: reintroduce support for IE star-declaration hack
- CSS bugfix:
margin
andpadding
now check if values that are functions (such ascalc()
) are equal and thus eligible for collapsing - CSS bugfix: parse bad declarations better
- CSS bugfix: add space for attribute selector case insensitivity between the value and
i
as ininput[type="radio" i]
- CSS bugfix: do not collapse
outline
to0
but tonone
- CSS bugfix: opacity for
rgba()
andhsla()
in CSS2 cannot be rewritten as#rrggbbaa
- SVG bugfix: only use the first pair of coordinates for
M
to move back to when encounteringZ
Bugfixes and bash completion
- CLI: Add bash completion for the
minify
command - CLI: improved error messages
- CLI bugfix: don't open all files at once when concatenating, which usually panics when >10000 files are open
- CLI bugfix: don't minify modified files twice when watching them
- Bugfix: prevent panic on long decimals with negative exponent, where rewriting would previously cause longer numbers
- HTML: accept alternative syntax for MS conditional comments
- HTML bugfix:
draggable
is not a boolean - HTML bugfix: do not assume mediatype in
<meta content="x">
- CSS: add option for CSS2 numbers without exponents
- CSS: trim space in
url()
- CSS: minify
box-shadow
,background
and@import
better - CSS bugfix: prevent panic for functions with no arguments or end parenthesis
- CSS bugfix: keep dimensions for zeros in
flex
property - CSS bugfix: keep other values for
outline
andborder
when width is zero - CSS bugfix: font
normal
now handled - CSS bugfix: add quotes to unquotes
url()
when we can remove theurl
function - CSS bugfix: only omit number dimensions for and
- JS bugfix: ASI behaviour for template literals
- JS bugfix: replace comment as space when comment is removed
- JS bugfix: divide by regular expression
- SVG: don't remove empty groups anymore, as CSS or JS might rely on them
- SVG bugfix: prevent panic on invalid pathdata for arcs
Bugfixes found by fuzz testing
This release fixes a number of out-of-bounds panics that could arise in HTML, XML and JS sources. It also allows HTML sources to contain the NULL byte.
Remove dependencies on buffer and strconv
v2.3.3 Change buffer to parse/buffer
v2.3.1
Performance
- Large performance increase by using a buffer that holds all contents, instead of a streaming buffer: 9904fe7
- Add standardized samples for benchmark tests
- Parsing errors now show line number, column and context (the content of the offending line)
- HTML: optimize
a
minification
v2.2.0
This is an incremental update over v2.1.0.
Changelog:
- CSS: properly handle bad declarations
- CSS: parse custom properties
- HTML: option to keep conditional comments
- Remove Content-Length in middleware
- HTML: attribute
spellcheck
is not a boolean - JS: improved parsing of edge cases
CLI:
- Limit maximum concurrency for opening files to 50 (default)
SVG
This v2.1 release added a much improved SVG minifier. Equinox has been added to distribute binaries and make installation easier, see Equinox (which says version 2.1.5). The CLI tool has matured and various bugfixes and feature requests are in this release.
Change log:
- HTML: do not keep IE conditional comments
- HTML: do not remove CDATA tags, as CDATA is invalid HTML anyways
- HTML: option to keep document tags (
html
,head
andbody
) - CSS/SVG: decimal precision can be set in the options
- SVG: more advanced minification
- export
MinifierFunc
- new
Match
function that returns the minifier function that gets matched to a mediatype - parsers return an error when they stop before the EOF
ResponseWriter
andMiddleware
functionality added
Bugfixes:
- HTML: whitespace around
img
and similar inline tags preserved - HTML: whitespace within
pre
tag properly preserved - HTML: the
math
andsvg
tags themselves are now parsed by their respective parsers - CSS/SVG: valid rounding and truncating of decimals
- CSS: do not lowercase all identifiers, as they may be
<custom-ident>
- CSS:
rgba
andhsla
now work properly - CSS: keep certain required number dimensions
- SVG: path data for arc; sweep and large-arg flags are now treated as booleans
- JS: keep newline or semicolon before
!function(){}
- JS: keep newline before lines that start with a string in certain instances, the original JSMin does not handle this
- JS: keep newline between
}
and string or ident
CLI:
- Add concatenation support
- Add more support for file and directory watching
- Only overwrite files when explicitly set output equal to input, previously an empty output would imply overwriting, now it means writing to
stdout
as intended
Options
This v2 releases introduces passing options to minifiers. This is a feature that resulted in an API change, additionally I did some API clean up as well. This works with parse-v2.0.0.
Furthermore, performance of several components has been improved. Tests have been added and improved.
Change log:
- options have been added
Reader
andWriter
functions are added- whitespace trimming doesn't convert newline to space if it can't remove it
- bang-comments are preserved
- improved CDATA processing
- HTML URL minification
Bugfixes:
- HTML: mediatype attribute in foreign/style/script wasn't copied
- HTML/XML: don't panic on early ending end tags
- SVG: allow single quotes attributes
- SVG: keep M command character
CLI changes:
- complete refactor allowing for a variety of inputs (streams, files, directories)
- more parameters such as watching directory changes, recursive minification and options for the minifiers
- processes files in parallel