html-minifier-next 4.8.0 → 4.8.3
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 +18 -19
- package/dist/htmlminifier.cjs +1858 -1792
- package/dist/htmlminifier.esm.bundle.js +33608 -33477
- package/dist/types/htmlminifier.d.ts +1 -1
- package/dist/types/htmlminifier.d.ts.map +1 -1
- package/dist/types/htmlparser.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/htmlminifier.js +1851 -1794
- package/src/htmlparser.js +10 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/html-minifier-next) [](https://github.com/j9t/html-minifier-next/actions) [](https://socket.dev/npm/package/html-minifier-next)
|
|
4
4
|
|
|
5
|
-
HTML Minifier Next (HMN) is a
|
|
5
|
+
HTML Minifier Next (HMN) is a **super-configurable, well-tested, JavaScript-based HTML minifier**.
|
|
6
6
|
|
|
7
7
|
The project was based on [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 backwards-compatible with both. The project was set up because as of 2025, both HTML Minifier Terser and HTML Minifier had been unmaintained for a few years. As the project seems maintainable [to me, [Jens](https://meiert.com/)]—even more so with community support—, it’s being [updated, extended, and documented](https://github.com/j9t/html-minifier-next/blob/main/CHANGELOG.md) further in this place.
|
|
8
8
|
|
|
@@ -227,33 +227,32 @@ const result = await minify(html, {
|
|
|
227
227
|
How does HTML Minifier Next compare to other minifiers? (All with the most aggressive settings, though without [hyper-optimization](https://meiert.com/blog/the-ways-of-writing-html/#toc-hyper-optimized). Minimize does not minify CSS or JS.)
|
|
228
228
|
|
|
229
229
|
<!-- Auto-generated benchmarks, don’t edit -->
|
|
230
|
-
| Site | Original Size (KB) | [HTML Minifier Next](https://github.com/j9t/html-minifier-next)<br
|
|
230
|
+
| Site | Original Size (KB) | [HTML Minifier Next](https://github.com/j9t/html-minifier-next)<br>[](https://socket.dev/npm/package/html-minifier-next) | [HTML Minifier Terser](https://github.com/terser/html-minifier-terser)<br>[](https://socket.dev/npm/package/html-minifier-terser) | [htmlnano](https://github.com/posthtml/htmlnano)<br>[](https://socket.dev/npm/package/htmlnano) | [@swc/html](https://github.com/swc-project/swc)<br>[](https://socket.dev/npm/package/@swc/html) | [minify-html](https://github.com/wilsonzlin/minify-html)<br>[](https://socket.dev/npm/package/@minify-html/node) | [minimize](https://github.com/Swaagie/minimize)<br>[](https://socket.dev/npm/package/minimize) | [htmlcompressor.com](https://htmlcompressor.com/) |
|
|
231
231
|
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
232
232
|
| [A List Apart](https://alistapart.com/) | 59 | **49** | 50 | 51 | 52 | 51 | 54 | 52 |
|
|
233
|
-
| [Apple](https://www.apple.com/) |
|
|
234
|
-
| [BBC](https://www.bbc.co.uk/) |
|
|
235
|
-
| [CSS-Tricks](https://css-tricks.com/) | 161 | 121 | **119** |
|
|
236
|
-
| [ECMAScript](https://tc39.es/ecma262/) |
|
|
237
|
-
| [EFF](https://www.eff.org/) | 55 | **47** | **47** |
|
|
238
|
-
| [FAZ](https://www.faz.net/aktuell/) |
|
|
239
|
-
| [Frontend Dogma](https://frontenddogma.com/) |
|
|
240
|
-
| [Google](https://www.google.com/) |
|
|
241
|
-
| [Ground News](https://ground.news/) | 2345 | **2060** | 2063 | 2155 | 2176 | 2181 | 2332 | n/a |
|
|
233
|
+
| [Apple](https://www.apple.com/) | 258 | **202** | **202** | 230 | 233 | 234 | 236 | 237 |
|
|
234
|
+
| [BBC](https://www.bbc.co.uk/) | 633 | **575** | 585 | 594 | 594 | 595 | 628 | n/a |
|
|
235
|
+
| [CSS-Tricks](https://css-tricks.com/) | 161 | 121 | **119** | 126 | 141 | 141 | 147 | 143 |
|
|
236
|
+
| [ECMAScript](https://tc39.es/ecma262/) | 7238 | **6341** | **6341** | 6561 | 6444 | 6567 | 6614 | n/a |
|
|
237
|
+
| [EFF](https://www.eff.org/) | 55 | **47** | **47** | 50 | 48 | 49 | 50 | 50 |
|
|
238
|
+
| [FAZ](https://www.faz.net/aktuell/) | 1573 | 1465 | 1470 | **1411** | 1498 | 1509 | 1520 | n/a |
|
|
239
|
+
| [Frontend Dogma](https://frontenddogma.com/) | 222 | **213** | **213** | 234 | 219 | 221 | 239 | 220 |
|
|
240
|
+
| [Google](https://www.google.com/) | 76 | **71** | 72 | n/a | 72 | 73 | 76 | 75 |
|
|
242
241
|
| [HTML Living Standard](https://html.spec.whatwg.org/multipage/) | 149 | **147** | **147** | 153 | **147** | 149 | 155 | 149 |
|
|
243
242
|
| [Igalia](https://www.igalia.com/) | 49 | **33** | **33** | 35 | 35 | 35 | 36 | 36 |
|
|
244
|
-
| [Leanpub](https://leanpub.com/) |
|
|
243
|
+
| [Leanpub](https://leanpub.com/) | 1457 | **1225** | **1225** | 1232 | 1231 | 1226 | 1451 | n/a |
|
|
245
244
|
| [Mastodon](https://mastodon.social/explore) | 35 | **26** | **26** | 30 | 33 | 33 | 34 | 34 |
|
|
246
245
|
| [MDN](https://developer.mozilla.org/en-US/) | 107 | **62** | **62** | 64 | 64 | 65 | 67 | 68 |
|
|
247
246
|
| [Middle East Eye](https://www.middleeasteye.net/) | 222 | **195** | **195** | 202 | 200 | 200 | 202 | 203 |
|
|
248
247
|
| [Nielsen Norman Group](https://www.nngroup.com/) | 84 | 71 | 71 | **53** | 71 | 72 | 74 | 73 |
|
|
249
|
-
| [SitePoint](https://www.sitepoint.com/) |
|
|
250
|
-
| [TetraLogical](https://tetralogical.com/) | 44 | 38 | 38 | **35** |
|
|
248
|
+
| [SitePoint](https://www.sitepoint.com/) | 495 | **353** | **353** | 431 | 469 | 473 | 491 | n/a |
|
|
249
|
+
| [TetraLogical](https://tetralogical.com/) | 44 | 38 | 38 | **35** | 37 | 38 | 39 | 39 |
|
|
251
250
|
| [TPGi](https://www.tpgi.com/) | 99 | **79** | **79** | 84 | 84 | 84 | 88 | 86 |
|
|
252
|
-
| [United Nations](https://www.un.org/en/) |
|
|
253
|
-
| [W3C](https://www.w3.org/) | 50 | **36** | **36** | 38 | 38 | 38 | 40 |
|
|
254
|
-
| **Average processing time** | |
|
|
251
|
+
| [United Nations](https://www.un.org/en/) | 154 | **115** | 116 | 123 | 127 | 127 | 133 | 126 |
|
|
252
|
+
| [W3C](https://www.w3.org/) | 50 | **36** | **36** | 38 | 38 | 38 | 40 | 39 |
|
|
253
|
+
| **Average processing time** | | 352 ms (21/21) | 401 ms (21/21) | 175 ms (20/21) | 56 ms (21/21) | **17 ms (21/21)** | 395 ms (21/21) | 1481 ms (16/21) |
|
|
255
254
|
|
|
256
|
-
(Last updated: Dec
|
|
255
|
+
(Last updated: Dec 10, 2025)
|
|
257
256
|
<!-- End auto-generated -->
|
|
258
257
|
|
|
259
258
|
## Examples
|
|
@@ -393,7 +392,7 @@ ignoreCustomFragments: [/\{\{[\s\S]{0,500}?\}\}/]
|
|
|
393
392
|
|
|
394
393
|
**Important:** When using custom `ignoreCustomFragments`, the minifier automatically applies bounded quantifiers to prevent ReDoS attacks, but you can also write safer patterns yourself using explicit bounds.
|
|
395
394
|
|
|
396
|
-
## Running HTML Minifier Next
|
|
395
|
+
## Running HTML Minifier Next locally
|
|
397
396
|
|
|
398
397
|
### Local server
|
|
399
398
|
|