html-minifier 3.5.8 → 3.5.12
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/LICENSE +1 -1
- package/README.md +11 -11
- package/cli.js +7 -4
- package/package.json +3 -3
- package/src/htmlminifier.js +13 -6
- package/src/htmlparser.js +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -22,19 +22,19 @@ How does HTMLMinifier compare to other solutions — [HTML Minifier from Will Pe
|
|
|
22
22
|
|
|
23
23
|
| Site | Original size *(KB)* | HTMLMinifier | minimize | Will Peavy | htmlcompressor.com |
|
|
24
24
|
| ---------------------------------------------------------------------------- |:--------------------:| ------------:| --------:| ----------:| ------------------:|
|
|
25
|
-
| [Google](https://www.google.com/) | 46 | **
|
|
26
|
-
| [HTMLMinifier](https://github.com/kangax/html-minifier) |
|
|
27
|
-
| [
|
|
28
|
-
| [
|
|
29
|
-
| [Stack Overflow](https://stackoverflow.com/) |
|
|
25
|
+
| [Google](https://www.google.com/) | 46 | **42** | 46 | 47 | 46 |
|
|
26
|
+
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 137 | **107** | 115 | 120 | 115 |
|
|
27
|
+
| [Twitter](https://twitter.com/) | 141 | **103** | 133 | 155 | 133 |
|
|
28
|
+
| [New York Times](https://www.nytimes.com/) | 234 | **162** | 183 | 179 | 167 |
|
|
29
|
+
| [Stack Overflow](https://stackoverflow.com/) | 254 | **199** | 209 | 218 | 206 |
|
|
30
|
+
| [BBC](https://www.bbc.co.uk/) | 271 | **220** | 264 | 267 | 252 |
|
|
30
31
|
| [Bootstrap CSS](https://getbootstrap.com/docs/3.3/css/) | 272 | **260** | 269 | 229 | 269 |
|
|
31
|
-
| [
|
|
32
|
-
| [
|
|
33
|
-
| [
|
|
34
|
-
| [NBC](https://www.nbc.com/) | 646 | **613** | 642 | 646 | n/a |
|
|
32
|
+
| [Amazon](https://www.amazon.co.uk/) | 374 | **320** | 360 | 372 | n/a |
|
|
33
|
+
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 473 | **441** | 457 | 472 | 456 |
|
|
34
|
+
| [NBC](https://www.nbc.com/) | 684 | **645** | 680 | 683 | n/a |
|
|
35
35
|
| [Eloquent Javascript](https://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |
|
|
36
|
-
| [ES6 table](https://kangax.github.io/compat-table/es6/) |
|
|
37
|
-
| [ES6 draft](https://tc39.github.io/ecma262/) |
|
|
36
|
+
| [ES6 table](https://kangax.github.io/compat-table/es6/) | 4799 | **4087** | 4539 | n/a | n/a |
|
|
37
|
+
| [ES6 draft](https://tc39.github.io/ecma262/) | 6098 | **5434** | 5596 | n/a | n/a |
|
|
38
38
|
|
|
39
39
|
## Options Quick Reference
|
|
40
40
|
|
package/cli.js
CHANGED
|
@@ -139,13 +139,16 @@ var mainOptions = {
|
|
|
139
139
|
var mainOptionKeys = Object.keys(mainOptions);
|
|
140
140
|
mainOptionKeys.forEach(function(key) {
|
|
141
141
|
var option = mainOptions[key];
|
|
142
|
-
key = '--' + paramCase(key);
|
|
143
142
|
if (Array.isArray(option)) {
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
key = '--' + paramCase(key);
|
|
144
|
+
key += option[1] === parseJSON ? ' [value]' : ' <value>';
|
|
145
|
+
program.option(key, option[0], option[1]);
|
|
146
|
+
}
|
|
147
|
+
else if (~['html5', 'includeAutoGeneratedTags'].indexOf(key)) {
|
|
148
|
+
program.option('--no-' + paramCase(key), option);
|
|
146
149
|
}
|
|
147
150
|
else {
|
|
148
|
-
program.option(key, option);
|
|
151
|
+
program.option('--' + paramCase(key), option);
|
|
149
152
|
}
|
|
150
153
|
});
|
|
151
154
|
program.option('-o --output <file>', 'Specify output file (if not specified STDOUT will be used for output)');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-minifier",
|
|
3
3
|
"description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
|
|
4
|
-
"version": "3.5.
|
|
4
|
+
"version": "3.5.12",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
7
7
|
"compress",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"camel-case": "3.0.x",
|
|
58
58
|
"clean-css": "4.1.x",
|
|
59
|
-
"commander": "2.
|
|
59
|
+
"commander": "2.15.x",
|
|
60
60
|
"he": "1.1.x",
|
|
61
61
|
"ncname": "1.0.x",
|
|
62
62
|
"param-case": "2.1.x",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"chalk": "2.3.x",
|
|
77
77
|
"cli-table": "0.3.x",
|
|
78
78
|
"lzma": "2.3.x",
|
|
79
|
-
"minimize": "2.
|
|
79
|
+
"minimize": "2.2.x",
|
|
80
80
|
"progress": "2.0.x"
|
|
81
81
|
},
|
|
82
82
|
"files": [
|
package/src/htmlminifier.js
CHANGED
|
@@ -67,7 +67,7 @@ function collapseWhitespace(str, options, trimLeft, trimRight, collapseAll) {
|
|
|
67
67
|
|
|
68
68
|
var createMapFromString = utils.createMapFromString;
|
|
69
69
|
// non-empty tags that will maintain whitespace around them
|
|
70
|
-
var inlineTags = createMapFromString('a,abbr,acronym,b,bdi,bdo,big,button,cite,code,del,dfn,em,font,i,ins,kbd,mark,math,nobr,q,rt,rp,s,samp,small,span,strike,strong,sub,sup,svg,time,tt,u,var');
|
|
70
|
+
var inlineTags = createMapFromString('a,abbr,acronym,b,bdi,bdo,big,button,cite,code,del,dfn,em,font,i,ins,kbd,label,mark,math,nobr,object,q,rt,rp,s,samp,select,small,span,strike,strong,sub,sup,svg,textarea,time,tt,u,var');
|
|
71
71
|
// non-empty tags that will maintain whitespace within them
|
|
72
72
|
var inlineTextTags = createMapFromString('a,abbr,acronym,b,big,del,em,font,i,ins,kbd,mark,nobr,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var');
|
|
73
73
|
// self-closing tags that will maintain whitespace around them
|
|
@@ -996,11 +996,13 @@ function minify(value, options, partialMarkup) {
|
|
|
996
996
|
if (!stackNoTrimWhitespace.length) {
|
|
997
997
|
squashTrailingWhitespace(tag);
|
|
998
998
|
}
|
|
999
|
-
if (!
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
999
|
+
if (!unary) {
|
|
1000
|
+
if (!_canTrimWhitespace(tag, attrs) || stackNoTrimWhitespace.length) {
|
|
1001
|
+
stackNoTrimWhitespace.push(tag);
|
|
1002
|
+
}
|
|
1003
|
+
if (!_canCollapseWhitespace(tag, attrs) || stackNoCollapseWhitespace.length) {
|
|
1004
|
+
stackNoCollapseWhitespace.push(tag);
|
|
1005
|
+
}
|
|
1004
1006
|
}
|
|
1005
1007
|
}
|
|
1006
1008
|
|
|
@@ -1184,6 +1186,11 @@ function minify(value, options, partialMarkup) {
|
|
|
1184
1186
|
// https://mathiasbynens.be/notes/ambiguous-ampersands
|
|
1185
1187
|
text = text.replace(/&(#?[0-9a-zA-Z]+;)/g, '&$1').replace(/</g, '<');
|
|
1186
1188
|
}
|
|
1189
|
+
if (uidPattern && options.collapseWhitespace && stackNoTrimWhitespace.length) {
|
|
1190
|
+
text = text.replace(uidPattern, function(match, prefix, index) {
|
|
1191
|
+
return ignoredCustomMarkupChunks[+index][0];
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1187
1194
|
currentChars += text;
|
|
1188
1195
|
if (text) {
|
|
1189
1196
|
hasChars = true;
|
package/src/htmlparser.js
CHANGED
|
@@ -80,7 +80,7 @@ var special = makeMap('script,style');
|
|
|
80
80
|
|
|
81
81
|
// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
|
|
82
82
|
// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
|
|
83
|
-
var nonPhrasing = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track');
|
|
83
|
+
var nonPhrasing = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,ol,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track,ul');
|
|
84
84
|
|
|
85
85
|
var reCache = {};
|
|
86
86
|
|