NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm
npm, #4953 most downloaded on npm
Highly effective, super-configurable, well-tested web page minifier
Latest stable
5.0.3
Last release 12 days ago
10 Nov 2026
Ships unpredictably
gaps range from 1 weeks to 7.6 years
Nearly every release is documented
notes for 56 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
15 years old
84 releases · first in 2011
Drag across the ruler to compare, or tap a release to open it.
Fixed mergeScripts joining scripts with only a newline after a last line holding // (as in a URL), which made the next script a call where it starts w
mergeScripts joining scripts with only a newline after a last line holding // (as in a URL), which made the next script a call where it starts with ( or [ (e.g., a="https://b" before (c)())collapseWhitespace removing spaces that render:
<a><img></a> text)bdi, bdo, cite, code, dfn, label, q, and ruby elements next to text (e.g., a<code> b</code>)svg and math elements, after a no-break space, around end tags that get dropped, and before removed comments next to text<!-- <script>…</script> -->, which browsers end only at a later </script>: The real end tag was dropped, which made the rest of the document script textremoveEmptyElements with removeOptionalTags mishandling what surrounds removed elements:
body (e.g., a script or title)<a><p>b</p><footer></footer></a> lost </p>, and without a body start tag before a removed element, a following script moved to the head)removeEmptyElements removing an element that closes another one with no end tag, which moved what follows into that other element (e.g., <p>a<div></div>b became <p>ab)removeEmptyElements removing empty html, head, and body elements with attributes, which browsers don’t recreate (e.g., <body class="a"></body>), and frameset elements, without which browsers render what followsremoveRedundantAttributes, removeDefaultTypeAttributes, and removeEmptyAttributes removing attributes that a style element in the document selects on (e.g., type given input[type=text])removeRedundantAttributes removing name from a elements with a different id, which broke links to the namecollapseWhitespace removing a trailing newline from textarea elements, which is part of their value--!>, and <!--> and <!---> not being read as empty comments—with removeComments, content up to the next --> was deleted</tr> and </tbody> closing rows and sections that only have implied start tags were dropped, merging table rowstr and section start tags didn’t close an implied cell, which removeEmptyElements saw as emptying the row<a><div></a>x</div>), and weren’t ignored from within a table when the element is outside it<span><div></span>x</div>)table or, for li, a list (e.g., <li><ul></li></ul>x lost </ul>)removeEmptyElements losing track of what is open after the end tag of a formatting element with a block element open inside it (e.g., <pre><b><p></b>a</p></pre> kept whitespace after it, and <b><p></b></p>x lost </b>)PUBLIC "a b")removeOptionalTags could leave one first and have it set the document mode (e.g., <body></body><!doctype html>)removeOptionalTags omitting the body start tag before base, basefont, bgsound, noframes, and title elements, which moved them to the headminifyCSS emptying invalid media queries, which made the style sheet apply (e.g., media="only screen and 8px)")<a href="x""target="_blank"> into a real target attribute—such a tag is now a parse error, and with continueOnParseError keeps its "target attributecontinueOnParseError turning tags with quotes in attribute names into text (e.g., <img alt="a "b" c">, with decodeEntities, became <img…)svg and math elements being read as comments, svg elements in annotation-xml being read as MathML, and isindex being read as a void elementnpm test compares parse5 trees and rendered whitespace across option combinations, generated markup, and html5lib’s parser tests, and npm run test:equivalence does so for the real-world corpus--input-dir, --zero) skip and report a file that fails rather than stop at it; a run with failures ends by listing the files and exits with code 1Your coding agent can read these notes before it upgrades. Set up the MCP server →
Fixed minifyCSS and minifyJS deleting or breaking custom fragments that start a rule or statement, follow a case clause or label, or sit in an @charse
minifyCSS and minifyJS deleting or breaking custom fragments that start a rule or statement, follow a case clause or label, or sit in an @charset, @import, or @namespace statement that would be dropped with them—CSS and JavaScript with such a fragment are now kept as written:
<style>b { top: 0 }\n<?php echo 1; ?></style> lost the PHP block<style>a { top: 0 }\n<?php echo 1; ?>\nb { top: 0 }</style> had its rules merged across the fragment<script>b()\n<?php if (x): ?>\nc()\n<?php endif; ?>\nd()</script> became a syntax error when the condition was false<style>@import <?= $u ?>;a{top:0}</style> lost the at-rule and the fragment<script>switch (a) { case 1: <?= $x ?> }</script> became if(1===a) <?= $x ?>, which is wrong if the fragment renders several statements<script>l: <?= $x ?>;</script> lost the labelcollapseBooleanAttributes turning hidden="until-found" into hidden, which made the content unfindablecollapseBooleanAttributes removing values that hold a custom fragment or htmlmin:ignore markup, which deleted template code (e.g., checked="<?= $c ?>"), and hidden and draggable values that hold a character reference, where only decoding shows the statecollapseBooleanAttributes removing the loop count of marquee elements (<marquee loop="3"> became <marquee loop>, which loops forever) and the values of attributes in SVG and MathML, where HTML’s Boolean attributes don’t apply (e.g., <mfenced open="["> lost its delimiter)collapseWhitespace removing spaces around and within SVG tspan and textPath elements, which joined words (e.g., a <tspan>b</tspan> became a<tspan>b</tspan>)collapseWhitespace collapsing whitespace within SVG script and style elements written in uppercase, which could break their code (e.g., a line comment in <svg><SCRIPT> swallowed the next line)collapseBooleanAttributes not collapsing alpha, headingreset, nomodule, playsinline, shadowrootclonable, shadowrootcustomelementregistry, shadowrootdelegatesfocus, and shadowrootserializablecollapseBooleanAttributes removing the values of defaultchecked, defaultmuted, defaultselected, enabled, indeterminate, pauseonexit, and visible, none of which are HTML attributes (e.g., <my-widget visible="false"> became <my-widget visible>)collapseBooleanAttributes leave custom elements alone, as these define what their attributes mean (e.g., <my-toggle checked="false"> keeps its value)Fixed two regular expression denial-of-service (ReDoS) issues (GHSA-9wmg-23wv-h297—thanks @aweiaaaaa), each causing quadratic (O(n²)) backtracking on
minify() path, now replaced by linear-time scans:
htmlmin:ignore block without tags, with collapseWhitespace enabledignoreCustomFragments match, with default optionsFixed decodeEntities (and minifyJS, in event handler attributes) turning an escaped ampersand into one that starts a character reference, which change
decodeEntities (and minifyJS, in event handler attributes) turning an escaped ampersand into one that starts a character reference, which changed the value browsers read (e.g., title="&copy b" → title="© b", read as “© b,” now kept; and in text, &#169 → ©, now &#169)decodeEntities (and minifyJS, in event handler attributes) leaving character references without a semicolon in attributes undecoded where browsers decode them (e.g., title="© b", now title="© b")hm as a short CLI command next to html-minifierhandle custom fragments within CSS/JS correctly (#1001, #1015)
continueOnParseError to treat invalid characters as text (#1004)commander 2.19.0grunt-contrib-uglify 4.0.1gruntify-eslint 5.0.0uglify-js 3.5.1p.a{color:red}p.b{color:red} becomes p.a,p.b{color:red})white becomes #fff)url("image.png") becomes url(image.png))::before becomes :before)level, compatibility, format) are no longer supportedminifyCSS option configuration has changed. Lightning CSS options differ from clean-css options. When passing an object to minifyCSS, use Lightning CSS configuration options:
targets: Browser targets for vendor prefix optimization (e.g., { chrome: 95, firefox: 90 })unusedSymbols: Array of CSS identifiers to remove during minificationerrorRecovery: Boolean to skip invalid CSS rules (disabled in Lightning CSS, but enabled by default in HMN)sourceMap: Boolean to generate source mapsIf you were passing configuration options to minifyCSS, review Lightning CSS documentation and update your configuration:
// Before (clean-css)
minify(html, {
minifyCSS: {
level: 2,
compatibility: 'ie8'
}
});
// After (Lightning CSS)
minify(html, {
minifyCSS: {
targets: { ie: 11, chrome: 95, firefox: 90 } // Browser targets object
}
});
To disable error recovery for strict CSS validation:
minify(html, {
minifyCSS: {
errorRecovery: false // Disable error recovery (enabled by default in HMN)
}
});
If you rely on specific CSS output formatting, review your CSS after upgrading as selector order and formatting may change due to better optimization.
Nothing published for this version
handle custom fragments inside CSS more gracefully (#928, #929, #950)
clean-css 4.2.1commander 2.17.1handle maxLineLength precisely around custom fragments & <!-- htmlmin:ignore --> (#930, #945)
maxLineLength precisely around custom fragments & <!-- htmlmin:ignore --> (#930, #945)https:// in documentation (#943)<!doctype html> for compressibility (#822, #944)fix DOCTYPE parsing (#938, #939)
--minify-urlscommander 2.16.0### Improvements - upgrade to uglify-js 3.4.2
uglify-js 3.4.2handle empty class attributes (#921, #922)
class attributes (#921, #922)supply context to minifyCSS custom processor
minifyCSS custom processor (#909)options (#910)grunt-browserify 5.3.0preserve whitespace around (#904, #905)
<ruby> (#904, #905)### Bug fixes - fix race in QUnit web test (#899) ### Improvements - reduce dependencies
fix corner case in decodeEntities (#893, #894)
decodeEntities (#893, #894)allow disabling of default flags on CLI (#860, #892)
handle ol & ul as non-phrasing content (#888, #889)
ol & ul as non-phrasing content (#888, #889)fix corner cases in collapseWhitespace (#878, #883)
collapseWhitespace (#878, #883)commander 2.14.1### Improvements - upgrade to uglify-js 3.3.1 - migrate from qunitjs to qunit
uglify-js 3.3.1qunitjs to qunitparse option element correctly (#866, #869)
option element correctly (#866, #869)chalk 2.3.0commander 2.12.1uglify-js 3.2.0correctly parse HTML4 nested inline elements (#857, #861)
upgrade to grunt-contrib-uglify 3.1.0
grunt-contrib-uglify 3.1.0upgrade to grunt-browserify 5.2.0
chalk 2.1.0grunt-browserify 5.2.0uglify-js 3.1.0cli does not override input file correctly (#829, 471f9f28173841f2d4b383d5b9dd963a51b21b32)
chalk 2.0.1commander 2.11.0gruntify-eslint 4.0.0propagate blocking of collapseWhitespace to inner elements
collapseWhitespace to inner elements (#817)improve usability of canCollapseWhitespace & canTrimWhitespace
canCollapseWhitespace & canTrimWhitespace (#813)upgrade to grunt-contrib-uglify 3.0.0
clean-css 4.1.2grunt-contrib-uglify 3.0.0uglify-js 3.0.5fix sortClassName on custom fragments (#805, #807)
sortClassName on custom fragments (#805, #807)upgrade to grunt-contrib-uglify 2.3.0
grunt-contrib-uglify 2.3.0progress 2.0.0uglify-js 2.8.22fix crash when specific class names are used with sortClassName (#794, #795)
sortClassName (#794, #795)fix minifyJS on event attributes (#792, #793)
### Improvements - upgrade to uglify-js 2.8.0
uglify-js 2.8.0 (#789)handle better in collapseWhitespace
better in collapseWhitespace (#785)handle whitespace around correctly (#777, #784)
preserve non-breaking spaces during collapseWhitespace (#777, #780)
collapseWhitespace (#777, #780)### Improvements - upgrade to clean-css 4.0.0
clean-css 4.0.0 (#772)retain attribute quotes around values containing custom fragments (#757, #760)
Added search and selectedcontent elements to HTML element registry for complete minification support and proper optional tag removal
search and selectedcontent elements to HTML element registry for complete minification support and proper optional tag removalfix backreferences usage in ignoreCustomFragments (#733, #738)
ignoreCustomFragments (#733, #738)handle line-breaks around custom fragments gracefully (#719, #720)
collapseWhitespace with trimCustomFragments (#722, #723)--dry/-d flag for dry run mode to process and report statistics without writing output files-o, --output flag, to clarify what it does and how it works-o file streams, skipping symlinks and the output subtree in directory mode, and handling EPIPE-o flag combinations, dry run error handlingmaxInputLength security option, CSS/JS error handling, <dialog> and <search> elementscollapseWhitespace removes attribute whitespaces in (#713, #715)
collapseWhitespace removes attribute whitespaces in <wbr> (#713, #715)removeComments overrides htmlmin:ignore sometimes (#696, #699)
removeComments overrides htmlmin:ignore sometimes (#696, #699)cli does not process subdirectories when --file-ext is specified (#686, #687)
--input-dir no long creates empty subdirectories (#688)support selective batch processing with --file-ext (#665, #680)
--file-ext (#665, #680)removeRedundantAttributes option now removes significantly more HTML default attribute values. This will result in more aggressive minification when this option is enabled, which may change existing output—keep an eye on CSS selectors, JavaScript queries, and tooling requirements. Newly removed default values include:
autocorrect="on", fetchpriority="auto", loading="eager", popovertargetaction="toggle"<button type="submit">, <form enctype="application/x-www-form-urlencoded">, <form method="get"> (both previously supported, now reorganized), <html dir="ltr">, <img decoding="auto">, <input colorspace="limited-srgb">, <input type="text"> (previously supported, now reorganized), <marquee behavior="scroll">, <marquee direction="left">, <style media="all">, <textarea wrap="soft">, <track kind="subtitles">fix whitespace interactions between minifyCSS and collapseWhitespace (#664, #676)
node:test runnerspaces are removed around (#666, #673)
<wbr> (#666, #673)dialog and search elements to <p> end tag omission rules per current HTML specification<ruby>, <rp>, <rt>, <rb>, <rtc>removeOptionalTags and collapseWhitespace options are enabledoptionalEndTag tracking through collapsible whitespace (unless conservativeCollapse is enabled)### Improvements - update to qunit 2.0.0
qunit 2.0.0 (#672)<tfoot> and <tbody> elements breaking HTML structure in nested tables, by ensuring table element closing only occurs within the current table scope### Improvements - update to change-case 3.0.0 - update to minimize 2.0.0
change-case 3.0.0minimize 2.0.0### Improvements - update to he 1.1.0
he 1.1.0command-line tool not working under Node.js 0.10 (#653, #654)
conservativeCollapse & preserveLineBreaks (#652, #655)degraded performance when sortAttributes or sortClassName is used
sortAttributes or sortClassName is used (#651)collapseWhitespace causes whitespace to shift around htmlmin:ignore (#641, #644)
collapseWhitespace causes whitespace to shift around htmlmin:ignore (#641, #644)prepare script to configure Git hooks path automaticallycommitlint-config-non-conventional dependencyincludeAutoGeneratedTags & removeOptionalTags removes meaningful content (#627, #629)
includeAutoGeneratedTags & removeOptionalTags removes meaningful content (#627, #629)benchmark.js uses live web sites as input (#612, #617)collapseWhitespace support for <nobr> (#628, #630)collapseWhitespace now handles inter-tag trailing whitespace (#631)options.lint migrates to HTMLLint (#80, #633)@eslint/js to development dependencies for improved lintingHTMLtoXML and HTMLtoDOM functions from the public API; these XML-related functions were outdated and no longer relevant to the library’s focus on HTML minificationHTMLtoXML, HTMLtoDOM)is-ci, lint-stagedquote character of attribute with empty string value is parsed incorrectly (#603, #605)
sortAttributes reorders attributes for optimal compression (#4, #594, #613)sortClassName recorders style classes for optimal compression (#267, #597, #613)removeScriptTypeAttributes and removeStyleLinkTypeAttributes cover wider range of cases (#607)decodeEntities minifies HTML Entity Characters (#75, #472, #608)some inline tags have significant trailing whitespaces removed by collapseWhitespace (#581, #583)
collapseWhitespace (#581, #583)remove{Comments,CDATASections}FromCDATA (#579, #586)behaviour mismatch on phrasing-content-only tags against web browsers (#557, #558, #559, #562, #565, #566, #577, #578)
cli.js does not throw Error object (#564)cli.js ignores -o <file> when reading from STDIN (#561)htmlmin:ignore & collapseWhitespace gives erroneous output (#572, #574)webpack cannot process html-minifier sources due to require() usage (#568)collapseWhitespace removes significant whitespace around font icons (#571)processConditionalComments to control minification of IE conditional comments (#563, #567)extraneous whitespace inserted by ignoreCustomFragments (#502, #505, #506, #509, #513, #545, #552)
ignoreCustomFragments (#502, #505, #506, #509, #513, #545, #552)removeOptionalTags on empty element crashes (#500, #508)HTMLParser halts on malformed markups (#177, #332, #507, #510, #512, #542)removeComments would give incorrect result if comment matches ignoreCustomFragments (#511, #515)removeOptionalTags too aggressive around non-HTML tags (#503, #514)collapseWhitespace within inline tags (#519)removeTagWhitespace does not work on the web (#528)cli cannot handle nested directories (#532, #533)removeEmptyElements always remove <iframe>, <audo> & <video> (#536, #538, #539)minifyJS does not work the same way on the web (#531)collapseWhitespace around comments and removeEmptyElements (#525)<script type="..."> (#521)jscs & jshint to eslint (#554)grunt test to cover browser tests (#537)Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.