html-minifier-next 1.1.2 → 1.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 +4 -4
- package/cli.js +1 -3
- package/package.json +5 -5
- package/src/htmlminifier.js +1 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
-
(This project
|
|
6
|
+
(This 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 will be updated and documented further in this place. For the time being, the following documentation largely matches the original project.)
|
|
7
7
|
|
|
8
8
|
HTMLMinifier is a highly **configurable, well-tested, JavaScript-based HTML minifier**.
|
|
9
9
|
|
|
@@ -30,7 +30,7 @@ For command line usage please see `html-minifier-next --help` for a list of avai
|
|
|
30
30
|
**Sample command line:**
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
html-minifier-next --collapse-whitespace --remove-comments --minify-js true
|
|
33
|
+
html-minifier-next --collapse-whitespace --remove-comments --minify-js true --input-dir=. --output-dir=example
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
### Node.js
|
|
@@ -44,13 +44,13 @@ const result = await minify('<p title="blah" id="moo">foo</p>', {
|
|
|
44
44
|
result; // '<p title=blah id=moo>foo</p>'
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
See [the
|
|
47
|
+
See [the original blog post](http://perfectionkills.com/experimenting-with-html-minifier) for details of [how it works](http://perfectionkills.com/experimenting-with-html-minifier#how_it_works), [description of each option](http://perfectionkills.com/experimenting-with-html-minifier#options), [testing results](http://perfectionkills.com/experimenting-with-html-minifier#field_testing), and [conclusions](http://perfectionkills.com/experimenting-with-html-minifier#cost_and_benefits).
|
|
48
48
|
|
|
49
49
|
For lint-like capabilities take a look at [HTMLLint](https://github.com/kangax/html-lint).
|
|
50
50
|
|
|
51
51
|
## Minification comparison
|
|
52
52
|
|
|
53
|
-
How does HTMLMinifier compare to other solutions
|
|
53
|
+
How does HTMLMinifier compare to other solutions—[HTML Minifier from Will Peavy](http://www.willpeavy.com/minifier/) (1st result in [Google search for “html minifier”](https://www.google.com/#q=html+minifier)) as well as [htmlcompressor.com](http://htmlcompressor.com) and [minimize](https://github.com/Swaagie/minimize)?
|
|
54
54
|
|
|
55
55
|
| Site | Original size (KB) | HTMLMinifier | minimize | htmlcompressor.com |
|
|
56
56
|
| --- | --- | --- | --- | --- |
|
package/cli.js
CHANGED
|
@@ -94,9 +94,7 @@ function parseJSONRegExpArray(value) {
|
|
|
94
94
|
return value && value.map(parseRegExp);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
return value;
|
|
99
|
-
}
|
|
97
|
+
const parseString = value => value;
|
|
100
98
|
|
|
101
99
|
const mainOptions = {
|
|
102
100
|
caseSensitive: 'Treat attributes in case sensitive manner (useful for SVG; e.g. viewBox)',
|
package/package.json
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
"commander": "^14.0.0",
|
|
11
11
|
"entities": "^6.0.1",
|
|
12
12
|
"relateurl": "^0.2.7",
|
|
13
|
-
"terser": "^5.
|
|
13
|
+
"terser": "^5.42.0"
|
|
14
14
|
},
|
|
15
15
|
"description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@commitlint/cli": "^19.8.1",
|
|
18
18
|
"@jest/globals": "^30.0.0",
|
|
19
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
19
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
20
20
|
"@rollup/plugin-json": "^6.1.0",
|
|
21
21
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
22
22
|
"@rollup/plugin-terser": "^0.4.4",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"is-ci": "^4.1.0",
|
|
28
28
|
"jest": "^30.0.0",
|
|
29
29
|
"jest-environment-jsdom": "^30.0.0",
|
|
30
|
-
"lint-staged": "^16.1.
|
|
31
|
-
"rollup": "^4.
|
|
30
|
+
"lint-staged": "^16.1.2",
|
|
31
|
+
"rollup": "^4.44.1",
|
|
32
32
|
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
33
33
|
"vite": "^6.3.5"
|
|
34
34
|
},
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"test:web": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --verbose --environment=jsdom"
|
|
87
87
|
},
|
|
88
88
|
"type": "module",
|
|
89
|
-
"version": "1.1.
|
|
89
|
+
"version": "1.1.4"
|
|
90
90
|
}
|
package/src/htmlminifier.js
CHANGED
|
@@ -7,9 +7,7 @@ import { HTMLParser, endTag } from './htmlparser.js';
|
|
|
7
7
|
import TokenChain from './tokenchain.js';
|
|
8
8
|
import { replaceAsync } from './utils.js';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
return str && str.replace(/^[ \n\r\t\f]+/, '').replace(/[ \n\r\t\f]+$/, '');
|
|
12
|
-
}
|
|
10
|
+
const trimWhitespace = str => str && str.replace(/^[ \n\r\t\f]+/, '').replace(/[ \n\r\t\f]+$/, '');
|
|
13
11
|
|
|
14
12
|
function collapseWhitespaceAll(str) {
|
|
15
13
|
// Non-breaking space is specifically handled inside the replacer function here:
|