html-minifier-next 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -23
- package/cli.js +0 -1
- package/dist/htmlminifier.cjs +1 -1
- package/dist/htmlminifier.esm.bundle.js +1 -1
- package/dist/htmlminifier.umd.bundle.js +1 -1
- package/dist/htmlminifier.umd.bundle.min.js +1 -1
- package/package.json +3 -4
- package/src/htmlminifier.js +0 -1
- package/src/htmlparser.js +1 -1
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/html-minifier-next)
|
|
4
4
|
[](https://github.com/j9t/html-minifier-next/actions?workflow=CI)
|
|
5
5
|
|
|
6
|
-
HTML Minifier Next is a highly **configurable, well-tested, JavaScript-based HTML minifier**.
|
|
6
|
+
HTML Minifier Next (HMN) is a highly **configurable, well-tested, JavaScript-based HTML minifier**.
|
|
7
7
|
|
|
8
|
-
The project has been based on [Terser’s html-minifier-terser](https://github.com/terser/html-minifier-terser), which in turn had been based on [Juriy Zaytsev’s html-minifier](https://github.com/kangax/html-minifier). It was set up because as of 2025, both html-minifier-terser and html-minifier have been unmaintained for some time. As the project seems maintainable [to me, [Jens](https://meiert.com/)]—even more so with community support—, it
|
|
8
|
+
The project has been based on [Terser’s html-minifier-terser](https://github.com/terser/html-minifier-terser), which in turn had been based on [Juriy Zaytsev’s html-minifier](https://github.com/kangax/html-minifier) (HMN offers additional features, but is compatible with both). It was set up because as of 2025, both html-minifier-terser and html-minifier have been unmaintained for some time. As the project seems maintainable [to me, [Jens](https://meiert.com/)]—even more so with community support—, it’s being updated and documented further in this place.
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -127,27 +127,29 @@ For lint-like capabilities take a look at [HTMLLint](https://github.com/kangax/h
|
|
|
127
127
|
|
|
128
128
|
## Minification comparison
|
|
129
129
|
|
|
130
|
-
How does HTML Minifier Next compare to other solutions, like [minimize](https://github.com/Swaagie/minimize), [htmlcompressor.com](http://htmlcompressor.com/), [htmlnano](https://github.com/posthtml/htmlnano), and [minify-html](https://github.com/wilsonzlin/minify-html)?
|
|
130
|
+
How does HTML Minifier Next compare to other solutions, like [minimize](https://github.com/Swaagie/minimize), [htmlcompressor.com](http://htmlcompressor.com/), [htmlnano](https://github.com/posthtml/htmlnano), and [minify-html](https://github.com/wilsonzlin/minify-html)? (All with the most aggressive settings, but without [hyper-optimization](https://meiert.com/blog/the-ways-of-writing-html/#toc-hyper-optimized).)
|
|
131
131
|
|
|
132
|
-
| Site | Original size (KB) | HTML Minifier Next | minimize |
|
|
132
|
+
| Site | Original size (KB) | HTML Minifier Next | minimize | htmlcompressor.com | htmlnano | minify-html |
|
|
133
133
|
| --- | --- | --- | --- | --- | --- | --- |
|
|
134
|
-
| [A List Apart](https://alistapart.com/) |
|
|
135
|
-
| [Amazon](https://www.amazon.com/) |
|
|
136
|
-
| [
|
|
137
|
-
| [
|
|
138
|
-
| [
|
|
139
|
-
| [
|
|
140
|
-
| [
|
|
141
|
-
| [FAZ](https://www.faz.net/aktuell/) |
|
|
142
|
-
| [Frontend Dogma](https://frontenddogma.com/) |
|
|
143
|
-
| [Google](https://www.google.com/) |
|
|
144
|
-
| [
|
|
145
|
-
| [
|
|
146
|
-
| [
|
|
147
|
-
| [
|
|
148
|
-
| [
|
|
149
|
-
| [
|
|
150
|
-
| [
|
|
134
|
+
| [A List Apart](https://alistapart.com/) | 63 | **54** | 58 | 57 | 55 | 56 |
|
|
135
|
+
| [Amazon](https://www.amazon.com/) | 5 | **3** | **3** | **3** | **3** | n/a |
|
|
136
|
+
| [Apple](https://www.apple.com/) | 212 | **171** | 198 | 195 | 189 | 194 |
|
|
137
|
+
| [BBC](https://www.bbc.co.uk/) | 742 | **683** | 736 | n/a | 698 | 699 |
|
|
138
|
+
| [CSS-Tricks](https://css-tricks.com/) | 11 | **6** | 11 | 10 | 7 | n/a |
|
|
139
|
+
| [ECMAScript](https://tc39.es/ecma262/) | 7205 | **6315** | 6585 | n/a | 6532 | 6538 |
|
|
140
|
+
| [EFF](https://www.eff.org/) | 60 | **51** | 55 | 55 | 54 | 53 |
|
|
141
|
+
| [FAZ](https://www.faz.net/aktuell/) | 1847 | 1728 | 1764 | n/a | **1630** | n/a |
|
|
142
|
+
| [Frontend Dogma](https://frontenddogma.com/) | 117 | **112** | 126 | 117 | 124 | 117 |
|
|
143
|
+
| [Google](https://www.google.com/) | 18 | **16** | 17 | 17 | **16** | n/a |
|
|
144
|
+
| [Ground News](https://ground.news/) | 1509 | **1287** | 1495 | n/a | 1386 | n/a |
|
|
145
|
+
| [HTML](https://html.spec.whatwg.org/multipage/) | 149 | **146** | 155 | 148 | 153 | 148 |
|
|
146
|
+
| [Leanpub](https://leanpub.com/) | 1361 | **1143** | 1355 | n/a | 1150 | n/a |
|
|
147
|
+
| [Mastodon](https://mastodon.social/explore) | 35 | **25** | 33 | 33 | 30 | 33 |
|
|
148
|
+
| [MDN](https://developer.mozilla.org/en-US/) | 104 | **62** | 67 | 68 | 64 | n/a |
|
|
149
|
+
| [Middle East Eye](https://www.middleeasteye.net/) | 221 | **194** | 201 | 202 | 201 | 199 |
|
|
150
|
+
| [SitePoint](https://www.sitepoint.com/) | 469 | **338** | 466 | n/a | 408 | 449 |
|
|
151
|
+
| [United Nations](https://www.un.org/en/) | 153 | **116** | 132 | 125 | 123 | 127 |
|
|
152
|
+
| [W3C](https://www.w3.org/) | 49 | **35** | 40 | 38 | 37 | 38 |
|
|
151
153
|
|
|
152
154
|
## Options quick reference
|
|
153
155
|
|
|
@@ -220,9 +222,9 @@ SVG elements are automatically recognized, and when they are minified, both case
|
|
|
220
222
|
|
|
221
223
|
HTML Minifier Next **can’t work with invalid or partial chunks of markup**. This is because it parses markup into a tree structure, then modifies it (removing anything that was specified for removal, ignoring anything that was specified to be ignored, etc.), then it creates a markup out of that tree and returns it.
|
|
222
224
|
|
|
223
|
-
|
|
225
|
+
_Input markup (e.g., `<p id="">foo`) → Internal representation of markup in a form of tree (e.g., `{ tag: "p", attr: "id", children: ["foo"] }`) → Transformation of internal representation (e.g., removal of `id` attribute) → Output of resulting markup (e.g., `<p>foo</p>`)_
|
|
224
226
|
|
|
225
|
-
|
|
227
|
+
HMN can’t know that the original markup represented only part of the tree. It parses a complete tree and, in doing so, loses information about the input being malformed or partial. As a result, it can’t emit a partial or malformed tree.
|
|
226
228
|
|
|
227
229
|
To validate HTML markup, use [the W3C validator](https://validator.w3.org/) or one of [several validator packages](https://meiert.com/blog/html-validator-packages/).
|
|
228
230
|
|
package/cli.js
CHANGED
package/dist/htmlminifier.cjs
CHANGED
|
@@ -21,7 +21,7 @@ async function replaceAsync(str, regex, asyncFn) {
|
|
|
21
21
|
|
|
22
22
|
/*!
|
|
23
23
|
* HTML Parser By John Resig (ejohn.org)
|
|
24
|
-
* Modified by Juriy
|
|
24
|
+
* Modified by Juriy “kangax” Zaytsev
|
|
25
25
|
* Original code by Erik Arvidsson, Mozilla Public License
|
|
26
26
|
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
|
|
27
27
|
*/
|
|
@@ -60211,7 +60211,7 @@ async function replaceAsync(str, regex, asyncFn) {
|
|
|
60211
60211
|
|
|
60212
60212
|
/*!
|
|
60213
60213
|
* HTML Parser By John Resig (ejohn.org)
|
|
60214
|
-
* Modified by Juriy
|
|
60214
|
+
* Modified by Juriy “kangax” Zaytsev
|
|
60215
60215
|
* Original code by Erik Arvidsson, Mozilla Public License
|
|
60216
60216
|
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
|
|
60217
60217
|
*/
|
|
@@ -60217,7 +60217,7 @@
|
|
|
60217
60217
|
|
|
60218
60218
|
/*!
|
|
60219
60219
|
* HTML Parser By John Resig (ejohn.org)
|
|
60220
|
-
* Modified by Juriy
|
|
60220
|
+
* Modified by Juriy “kangax” Zaytsev
|
|
60221
60221
|
* Original code by Erik Arvidsson, Mozilla Public License
|
|
60222
60222
|
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
|
|
60223
60223
|
*/
|