minify

Go minifiers for web formats

MIT License

Downloads
51K
Stars
3.6K
Committers
45

Bot releases are visible (Hide)

minify - v2.5.2

Published by tdewolff about 5 years ago

Bugfixes:

  • SVG: don't convert polyline/rect/polygon/line to path, which can break CSS, fixes #260
  • SVG: relative SVG Bézier commands not properly minified
  • CSS: don't remove whitespace in nested unknown at-rules, fixes #262
  • CSS: fix panic for background when it contains functions other than calc for background-position, fixes #263
  • CSS: fix panic for background-position with three numbers
  • CSS: fix panic for url() with only whitespace or only one quote
minify - v2.5.1

Published by tdewolff over 5 years ago

  • Remove import comments
  • SVG: do not convert line/rect to path if coordinates are relative percentages
  • CSS: fix bug with inline CSS encountering }
minify - v2.5.0

Published by tdewolff over 5 years ago

  • CSS: fix position information in error context
  • CSS: fix background-position panic with offsets that are zero
  • HTML: trim and collapse whitespace in certain attribute values
  • SVG: shorten cubic and quadratic Beziér path data to their shorter format or to line segments
minify -

Published by tdewolff over 5 years ago

  • When minifying floating points, remove trailing zeros and not other numbers
  • Make M concurrent-safe
  • HTML: keep double quotes around XML-flavour RDFa attributes
  • CSS: revert the use of the #RRGGBBAA format as proposed in Color Module Level 4 as it is not yet an official W3C recommendation
  • CSS: background-position (also within background) now works with 3 and 4 values as well
  • SVG: skipping metadata or rect tags properly even if they are closed by a void tag (like <rect/>)
  • SVG pathdata: when cursor doesn't move, don't emit any commands
minify - Go modules support #2

Published by tdewolff almost 6 years ago

I'm suspecting that go mod gets confused from a previously reverted v2.3.7 release, so just in case this is a new release that will hopefully fix:

$ go get -u github.com/tdewolff/minify/v2
go: github.com/tdewolff/minify/[email protected]: go.mod has non-.../v2 module path "github.com/tdewolff/minify" (and .../v2/go.mod does not exist) at revision v2.3.7
go get: error loading module requirements
minify - Go modules support

Published by tdewolff almost 6 years ago

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...

minify - Bugfixes and improved CSS minifier

Published by tdewolff almost 6 years ago

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() and hsl() with spaces instead of commas
  • CSS: improve minification for font, background, background-position, background-repeat, background-size, outline and border declarations
  • CSS: reintroduce support for IE star-declaration hack
  • CSS bugfix: margin and padding now check if values that are functions (such as calc()) 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 in input[type="radio" i]
  • CSS bugfix: do not collapse outline to 0 but to none
  • CSS bugfix: opacity for rgba() and hsla() in CSS2 cannot be rewritten as #rrggbbaa
  • SVG bugfix: only use the first pair of coordinates for M to move back to when encountering Z
minify - Bugfixes and bash completion

Published by tdewolff over 6 years ago

  • 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 and border when width is zero
  • CSS bugfix: font normal now handled
  • CSS bugfix: add quotes to unquotes url() when we can remove the url 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
minify - Bugfixes found by fuzz testing

Published by tdewolff almost 7 years ago

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.

minify - Remove dependencies on buffer and strconv

Published by tdewolff almost 7 years ago

minify - v2.3.1

Published by tdewolff almost 7 years ago

This release has binaries built by GoReleaser.

minify - Performance

Published by tdewolff almost 7 years ago

  • Large performance increase by using a buffer that holds all contents, instead of a streaming buffer: 9904fe70e1c1cb5217ed45b24bf9728de3ff10c2
  • 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
minify - v2.2.0

Published by tdewolff about 7 years ago

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)
minify - SVG

Published by tdewolff over 7 years ago

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 and body)
  • 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 and Middleware functionality added

Bugfixes:

  • HTML: whitespace around img and similar inline tags preserved
  • HTML: whitespace within pre tag properly preserved
  • HTML: the math and svg 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 and hsla 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
minify - Options

Published by tdewolff over 8 years ago

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 and Writer 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
minify - Zero-copy

Published by tdewolff almost 9 years ago

This uses a more efficient underlying buffer which removes any need to copy byte slices. All minifiers have higher performance, bugfixes and test refactoring.

minify - v1

Published by tdewolff about 9 years ago

This denotes a stable release point which is guaranteed to work in the future. Bugfixes and development is done on this version, while promising a stable API. Meanwhile work is put into v2.0.0 which will support options passing.

Package Rankings
Top 0.74% on Proxy.golang.org
Top 4.62% on Pypi.org
Top 6.62% on Alpine-edge
Top 8.91% on Alpine-v3.16
Top 9.39% on Alpine-v3.17
Top 2.74% on Alpine-v3.18
Top 3.27% on Npmjs.org
Badges
Extracted from project README
API reference Go Report Card codecov SiteGround