html-minifier-next 4.15.0 → 4.15.1
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 +14 -14
- package/dist/htmlminifier.cjs +2 -3
- package/dist/htmlminifier.esm.bundle.js +2 -3
- package/dist/types/htmlminifier.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/htmlminifier.js +2 -3
package/README.md
CHANGED
|
@@ -352,40 +352,40 @@ Available options:
|
|
|
352
352
|
|
|
353
353
|
## Minification comparison
|
|
354
354
|
|
|
355
|
-
How does HTML Minifier Next compare to other minifiers? (All minification with the most aggressive settings—though without [hyper-optimization](https://meiert.com/blog/the-ways-of-writing-html/#toc-hyper-optimized)—and against
|
|
355
|
+
How does HTML Minifier Next compare to other minifiers? (All minification with the most aggressive settings—though without [hyper-optimization](https://meiert.com/blog/the-ways-of-writing-html/#toc-hyper-optimized)—and against a wide range of pages. Note that HTML Minifier Terser may handle whitespace too aggressively and doesn’t currently—Dec 2025—support modern CSS syntax like CSS nesting. Minimize does not minify CSS and JS.)
|
|
356
356
|
|
|
357
357
|
<!-- Auto-generated benchmarks, don’t edit -->
|
|
358
358
|
| Site | Original Size (KB) | [HTML Minifier Next](https://github.com/j9t/html-minifier-next) ([config](https://github.com/j9t/html-minifier-next/blob/main/benchmarks/html-minifier.json))<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/) |
|
|
359
359
|
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
360
360
|
| [A List Apart](https://alistapart.com/) | 59 | **50** | **50** | 51 | 52 | 51 | 54 | 52 |
|
|
361
361
|
| [Apple](https://www.apple.com/) | 266 | **206** | 207 | 236 | 239 | 240 | 242 | 243 |
|
|
362
|
-
| [BBC](https://www.bbc.co.uk/) |
|
|
362
|
+
| [BBC](https://www.bbc.co.uk/) | 645 | **587** | 597 | 606 | 606 | 607 | 640 | n/a |
|
|
363
363
|
| [CERN](https://home.cern/) | 152 | **83** | 84 | 91 | 91 | 92 | 93 | 96 |
|
|
364
|
-
| [CSS-Tricks](https://css-tricks.com/) | 162 | **119** | 120 | 127 | 143 | 143 | 148 |
|
|
365
|
-
| [ECMAScript](https://tc39.es/ecma262/) | 7250 |
|
|
364
|
+
| [CSS-Tricks](https://css-tricks.com/) | 162 | **119** | 120 | 127 | 143 | 143 | 148 | 144 |
|
|
365
|
+
| [ECMAScript](https://tc39.es/ecma262/) | 7250 | 6401 | **6354** | 6573 | 6455 | 6578 | 6626 | n/a |
|
|
366
366
|
| [EDRi](https://edri.org/) | 80 | **59** | 60 | 70 | 70 | 71 | 75 | 73 |
|
|
367
|
-
| [EFF](https://www.eff.org/) | 55 | **46** | 47 | 49 | 48 |
|
|
367
|
+
| [EFF](https://www.eff.org/) | 55 | **46** | 47 | 49 | 48 | 48 | 50 | 50 |
|
|
368
368
|
| [European Alternatives](https://european-alternatives.eu/) | 48 | **30** | **30** | 32 | 32 | 32 | 32 | 32 |
|
|
369
|
-
| [FAZ](https://www.faz.net/aktuell/) |
|
|
369
|
+
| [FAZ](https://www.faz.net/aktuell/) | 1575 | 1467 | 1476 | **1413** | 1500 | 1511 | 1522 | n/a |
|
|
370
370
|
| [French Tech](https://lafrenchtech.gouv.fr/) | 152 | **122** | **122** | 126 | 125 | 125 | 132 | 127 |
|
|
371
371
|
| [Frontend Dogma](https://frontenddogma.com/) | 225 | **217** | **217** | 238 | 223 | 225 | 243 | 224 |
|
|
372
372
|
| [Google](https://www.google.com/) | 18 | **16** | 17 | 17 | 17 | 17 | 18 | 18 |
|
|
373
|
-
| [Ground News](https://ground.news/) |
|
|
373
|
+
| [Ground News](https://ground.news/) | 2106 | **1837** | 1838 | 1934 | 1962 | 1967 | 2093 | n/a |
|
|
374
374
|
| [HTML Living Standard](https://html.spec.whatwg.org/multipage/) | 149 | 148 | **147** | 153 | **147** | 149 | 155 | 149 |
|
|
375
|
-
| [Igalia](https://www.igalia.com/) | 50 | **
|
|
376
|
-
| [Leanpub](https://leanpub.com/) |
|
|
375
|
+
| [Igalia](https://www.igalia.com/) | 50 | **33** | **33** | 36 | 36 | 36 | 37 | 36 |
|
|
376
|
+
| [Leanpub](https://leanpub.com/) | 225 | 196 | **194** | 210 | 210 | 211 | 221 | 223 |
|
|
377
377
|
| [Mastodon](https://mastodon.social/explore) | 37 | **28** | **28** | 32 | 35 | 35 | 36 | 36 |
|
|
378
|
-
| [MDN](https://developer.mozilla.org/en-US/) |
|
|
379
|
-
| [Middle East Eye](https://www.middleeasteye.net/) |
|
|
378
|
+
| [MDN](https://developer.mozilla.org/en-US/) | 109 | **62** | **62** | 64 | 65 | 65 | 68 | 68 |
|
|
379
|
+
| [Middle East Eye](https://www.middleeasteye.net/) | 223 | **196** | **196** | 202 | 201 | 200 | 202 | 203 |
|
|
380
380
|
| [Nielsen Norman Group](https://www.nngroup.com/) | 86 | 68 | 74 | **55** | 74 | 75 | 77 | 76 |
|
|
381
381
|
| [SitePoint](https://www.sitepoint.com/) | 491 | **360** | **360** | 431 | 465 | 470 | 488 | n/a |
|
|
382
382
|
| [TetraLogical](https://tetralogical.com/) | 44 | 39 | 38 | **35** | 38 | 39 | 39 | 39 |
|
|
383
383
|
| [TPGi](https://www.tpgi.com/) | 175 | **159** | 161 | 160 | 164 | 166 | 172 | 172 |
|
|
384
|
-
| [United Nations](https://www.un.org/en/) | 152 | **113** | 115 |
|
|
384
|
+
| [United Nations](https://www.un.org/en/) | 152 | **113** | 115 | 121 | 125 | 125 | 131 | 124 |
|
|
385
385
|
| [W3C](https://www.w3.org/) | 50 | **36** | **36** | 39 | 38 | 38 | 41 | 39 |
|
|
386
|
-
| **Average processing time** | |
|
|
386
|
+
| **Average processing time** | | 267 ms (26/26) | 359 ms (26/26) | 160 ms (26/26) | 54 ms (26/26) | **16 ms (26/26)** | 313 ms (26/26) | 1572 ms (21/26) |
|
|
387
387
|
|
|
388
|
-
(Last updated: Dec
|
|
388
|
+
(Last updated: Dec 23, 2025)
|
|
389
389
|
<!-- End auto-generated -->
|
|
390
390
|
|
|
391
391
|
## Examples
|
package/dist/htmlminifier.cjs
CHANGED
|
@@ -3500,7 +3500,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
3500
3500
|
// `</head>` may be omitted if not followed by space or comment
|
|
3501
3501
|
// `</p>` may be omitted if no more content in non-`</a>` parent
|
|
3502
3502
|
// except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
|
|
3503
|
-
if (
|
|
3503
|
+
if (tag && optionalEndTag && !trailingTags.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineTags.has(tag))) {
|
|
3504
3504
|
removeEndTag();
|
|
3505
3505
|
}
|
|
3506
3506
|
optionalEndTag = optionalEndTags.has(tag) ? tag : '';
|
|
@@ -3678,8 +3678,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
3678
3678
|
const prevComment = buffer[buffer.length - 2];
|
|
3679
3679
|
|
|
3680
3680
|
// Check if previous item is whitespace-only and item before that is ignore-placeholder
|
|
3681
|
-
if (prevText && /^\s+$/.test(prevText) &&
|
|
3682
|
-
prevComment && uidIgnorePlaceholderPattern.test(prevComment)) {
|
|
3681
|
+
if (prevText && /^\s+$/.test(prevText) && prevComment && uidIgnorePlaceholderPattern.test(prevComment)) {
|
|
3683
3682
|
// Extract the index from both placeholders to check their content
|
|
3684
3683
|
const currentMatch = text.match(uidIgnorePlaceholderPattern);
|
|
3685
3684
|
const prevMatch = prevComment.match(uidIgnorePlaceholderPattern);
|
|
@@ -8642,7 +8642,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
8642
8642
|
// `</head>` may be omitted if not followed by space or comment
|
|
8643
8643
|
// `</p>` may be omitted if no more content in non-`</a>` parent
|
|
8644
8644
|
// except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
|
|
8645
|
-
if (
|
|
8645
|
+
if (tag && optionalEndTag && !trailingTags.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineTags.has(tag))) {
|
|
8646
8646
|
removeEndTag();
|
|
8647
8647
|
}
|
|
8648
8648
|
optionalEndTag = optionalEndTags.has(tag) ? tag : '';
|
|
@@ -8820,8 +8820,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
8820
8820
|
const prevComment = buffer[buffer.length - 2];
|
|
8821
8821
|
|
|
8822
8822
|
// Check if previous item is whitespace-only and item before that is ignore-placeholder
|
|
8823
|
-
if (prevText && /^\s+$/.test(prevText) &&
|
|
8824
|
-
prevComment && uidIgnorePlaceholderPattern.test(prevComment)) {
|
|
8823
|
+
if (prevText && /^\s+$/.test(prevText) && prevComment && uidIgnorePlaceholderPattern.test(prevComment)) {
|
|
8825
8824
|
// Extract the index from both placeholders to check their content
|
|
8826
8825
|
const currentMatch = text.match(uidIgnorePlaceholderPattern);
|
|
8827
8826
|
const prevMatch = prevComment.match(uidIgnorePlaceholderPattern);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AAu1CO,8BAJI,MAAM,YACN,eAAe,GACb,OAAO,CAAC,MAAM,CAAC,CAc3B;;;;;;;;;;;;UA7vCS,MAAM;YACN,MAAM;YACN,MAAM;mBACN,MAAM;iBACN,MAAM;kBACN,MAAM;;;;;;;;;;;;;4BAQN,CAAC,GAAG,EAAE,MAAM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d,cAAc"}
|
package/package.json
CHANGED
package/src/htmlminifier.js
CHANGED
|
@@ -1028,7 +1028,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1028
1028
|
// `</head>` may be omitted if not followed by space or comment
|
|
1029
1029
|
// `</p>` may be omitted if no more content in non-`</a>` parent
|
|
1030
1030
|
// except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
|
|
1031
|
-
if (
|
|
1031
|
+
if (tag && optionalEndTag && !trailingTags.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineTags.has(tag))) {
|
|
1032
1032
|
removeEndTag();
|
|
1033
1033
|
}
|
|
1034
1034
|
optionalEndTag = optionalEndTags.has(tag) ? tag : '';
|
|
@@ -1206,8 +1206,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1206
1206
|
const prevComment = buffer[buffer.length - 2];
|
|
1207
1207
|
|
|
1208
1208
|
// Check if previous item is whitespace-only and item before that is ignore-placeholder
|
|
1209
|
-
if (prevText && /^\s+$/.test(prevText) &&
|
|
1210
|
-
prevComment && uidIgnorePlaceholderPattern.test(prevComment)) {
|
|
1209
|
+
if (prevText && /^\s+$/.test(prevText) && prevComment && uidIgnorePlaceholderPattern.test(prevComment)) {
|
|
1211
1210
|
// Extract the index from both placeholders to check their content
|
|
1212
1211
|
const currentMatch = text.match(uidIgnorePlaceholderPattern);
|
|
1213
1212
|
const prevMatch = prevComment.match(uidIgnorePlaceholderPattern);
|