html-minifier-next 4.8.2 → 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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/html-minifier-next.svg)](https://www.npmjs.com/package/html-minifier-next) [![Build status](https://github.com/j9t/html-minifier-next/workflows/Tests/badge.svg)](https://github.com/j9t/html-minifier-next/actions) [![Socket](https://badge.socket.dev/npm/package/html-minifier-next)](https://socket.dev/npm/package/html-minifier-next)
4
4
 
5
- HTML Minifier Next (HMN) is a highly **configurable, well-tested, JavaScript-based HTML minifier**.
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
 
@@ -392,7 +392,7 @@ ignoreCustomFragments: [/\{\{[\s\S]{0,500}?\}\}/]
392
392
 
393
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.
394
394
 
395
- ## Running HTML Minifier Next
395
+ ## Running HTML Minifier Next locally
396
396
 
397
397
  ### Local server
398
398
 
@@ -1986,10 +1986,11 @@ function buildAttr(normalized, hasUnarySlash, options, isLast, uidAttr) {
1986
1986
  if (!isLast && !options.removeTagWhitespace) {
1987
1987
  emittedAttrValue += ' ';
1988
1988
  }
1989
- } else if (isLast && !hasUnarySlash && !/\/$/.test(attrValue)) {
1990
- // Make sure trailing slash is not interpreted as HTML self-closing tag
1989
+ } else if (isLast && !hasUnarySlash) {
1990
+ // Last attribute in a non-self-closing tag: no space needed
1991
1991
  emittedAttrValue = attrValue;
1992
1992
  } else {
1993
+ // Not last attribute, or is a self-closing tag: add space
1993
1994
  emittedAttrValue = attrValue + ' ';
1994
1995
  }
1995
1996
 
@@ -7128,10 +7128,11 @@ function buildAttr(normalized, hasUnarySlash, options, isLast, uidAttr) {
7128
7128
  if (!isLast && !options.removeTagWhitespace) {
7129
7129
  emittedAttrValue += ' ';
7130
7130
  }
7131
- } else if (isLast && !hasUnarySlash && !/\/$/.test(attrValue)) {
7132
- // Make sure trailing slash is not interpreted as HTML self-closing tag
7131
+ } else if (isLast && !hasUnarySlash) {
7132
+ // Last attribute in a non-self-closing tag: no space needed
7133
7133
  emittedAttrValue = attrValue;
7134
7134
  } else {
7135
+ // Not last attribute, or is a self-closing tag: add space
7135
7136
  emittedAttrValue = attrValue + ' ';
7136
7137
  }
7137
7138
 
@@ -1 +1 @@
1
- {"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AAoqEO,8BAJI,MAAM,YACN,eAAe,GACb,OAAO,CAAC,MAAM,CAAC,CAQ3B;;;;;;;;;;;;UA3oES,MAAM;YACN,MAAM;YACN,MAAM;mBACN,MAAM;iBACN,MAAM;kBACN,MAAM;;;;;;;;;;;;;4BAQN,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,qBAAqB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,KAAK,OAAO;;;;;;;wBAMjG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,KAAK,OAAO;;;;;;;;oBAMhH,OAAO;;;;;;;;gCAOP,OAAO;;;;;;;;kCAOP,OAAO;;;;;;;;yBAOP,O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,IAAI,GAAG,GAAG;;;;;;;4BAMV,OAAO;;;;;;;;qBAMP,OAAO;;;;;;;;;4BAOP,OAAO,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;;;;;;;;0BAQtD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;gCAOP,MAAM,EAAE;;;;;;;;yBAyBR,OAAO;;;;;;;;gCAOP,OAAO;;;;;;;iCAOP,OAAO;;;;;;;oCAMP,OAAO;;;;;;;;;;0BAMP,OAAO;;;;;;;;;qBASP,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;;;;;;;;;oBAQzD,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;;;;;;;;0BAQrC,OAAO;;;;;;;sBAOP,OAAO;;wBAnYkC,cAAc;0BAAd,cAAc;+BAAd,cAAc"}
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "relateurl": "^0.2.7",
14
14
  "terser": "^5.44.1"
15
15
  },
16
- "description": "Highly configurable, well-tested, JavaScript-based HTML minifier (enhanced successor of HTML Minifier)",
16
+ "description": "Super-configurable, well-tested, JavaScript-based HTML minifier (enhanced successor of HTML Minifier)",
17
17
  "devDependencies": {
18
18
  "@commitlint/cli": "^20.1.0",
19
19
  "@eslint/js": "^9.39.1",
@@ -84,5 +84,5 @@
84
84
  "test:watch": "node --test --watch tests/*.spec.js"
85
85
  },
86
86
  "type": "module",
87
- "version": "4.8.2"
87
+ "version": "4.8.3"
88
88
  }
@@ -1280,10 +1280,11 @@ function buildAttr(normalized, hasUnarySlash, options, isLast, uidAttr) {
1280
1280
  if (!isLast && !options.removeTagWhitespace) {
1281
1281
  emittedAttrValue += ' ';
1282
1282
  }
1283
- } else if (isLast && !hasUnarySlash && !/\/$/.test(attrValue)) {
1284
- // Make sure trailing slash is not interpreted as HTML self-closing tag
1283
+ } else if (isLast && !hasUnarySlash) {
1284
+ // Last attribute in a non-self-closing tag: no space needed
1285
1285
  emittedAttrValue = attrValue;
1286
1286
  } else {
1287
+ // Not last attribute, or is a self-closing tag: add space
1287
1288
  emittedAttrValue = attrValue + ' ';
1288
1289
  }
1289
1290