html-minifier 3.4.3 → 3.5.2
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 +11 -11
- package/package.json +5 -6
- package/src/htmlminifier.js +16 -24
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/) |
|
|
26
|
-
| [HTMLMinifier](https://github.com/kangax/html-minifier) |
|
|
27
|
-
| [CNN](http://www.cnn.com/) |
|
|
28
|
-
| [Amazon](http://www.amazon.co.uk/) |
|
|
29
|
-
| [
|
|
30
|
-
| [
|
|
31
|
-
| [
|
|
25
|
+
| [Google](https://www.google.com/) | 46 | **43** | 46 | 48 | 46 |
|
|
26
|
+
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 129 | **100** | 108 | 113 | 108 |
|
|
27
|
+
| [CNN](http://www.cnn.com/) | 134 | **123** | 131 | 132 | 127 |
|
|
28
|
+
| [Amazon](http://www.amazon.co.uk/) | 200 | **168** | 192 | 195 | n/a |
|
|
29
|
+
| [Stack Overflow](http://stackoverflow.com/) | 220 | **170** | 178 | 186 | 176 |
|
|
30
|
+
| [BBC](http://www.bbc.co.uk/) | 228 | **188** | 221 | 228 | 216 |
|
|
31
|
+
| [New York Times](http://www.nytimes.com/) | 235 | **158** | 181 | 178 | 165 |
|
|
32
32
|
| [Bootstrap CSS](http://getbootstrap.com/css/) | 272 | **260** | 269 | 229 | 269 |
|
|
33
|
-
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) |
|
|
34
|
-
| [NBC](http://www.nbc.com/) |
|
|
33
|
+
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 550 | **502** | 530 | 548 | 529 |
|
|
34
|
+
| [NBC](http://www.nbc.com/) | 649 | **617** | 646 | 649 | n/a |
|
|
35
35
|
| [Eloquent Javascript](http://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |
|
|
36
|
-
| [ES6 table](http://kangax.github.io/compat-table/es6/) |
|
|
37
|
-
| [ES6 draft](https://tc39.github.io/ecma262/) |
|
|
36
|
+
| [ES6 table](http://kangax.github.io/compat-table/es6/) | 4105 | **3467** | 3871 | n/a | n/a |
|
|
37
|
+
| [ES6 draft](https://tc39.github.io/ecma262/) | 5512 | **4919** | 5066 | n/a | n/a |
|
|
38
38
|
|
|
39
39
|
## Options Quick Reference
|
|
40
40
|
|
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.
|
|
4
|
+
"version": "3.5.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
7
7
|
"compress",
|
|
@@ -55,22 +55,21 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"camel-case": "3.0.x",
|
|
58
|
-
"clean-css": "4.
|
|
58
|
+
"clean-css": "4.1.x",
|
|
59
59
|
"commander": "2.9.x",
|
|
60
60
|
"he": "1.1.x",
|
|
61
61
|
"ncname": "1.0.x",
|
|
62
62
|
"param-case": "2.1.x",
|
|
63
63
|
"relateurl": "0.2.x",
|
|
64
|
-
"uglify-js": "
|
|
64
|
+
"uglify-js": "3.0.x"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"grunt": "1.0.x",
|
|
68
68
|
"grunt-browserify": "5.0.x",
|
|
69
|
-
"grunt-contrib-uglify": "
|
|
69
|
+
"grunt-contrib-uglify": "3.0.x",
|
|
70
70
|
"gruntify-eslint": "3.1.x",
|
|
71
71
|
"phantomjs-prebuilt": "2.1.x",
|
|
72
|
-
"qunitjs": "2.x"
|
|
73
|
-
"uglify-to-browserify": "1.0.x"
|
|
72
|
+
"qunitjs": "2.x"
|
|
74
73
|
},
|
|
75
74
|
"benchmarkDependencies": {
|
|
76
75
|
"brotli": "1.3.x",
|
package/src/htmlminifier.js
CHANGED
|
@@ -626,13 +626,11 @@ function processOptions(options) {
|
|
|
626
626
|
options.log = identity;
|
|
627
627
|
}
|
|
628
628
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
};
|
|
635
|
-
}
|
|
629
|
+
if (!options.canCollapseWhitespace) {
|
|
630
|
+
options.canCollapseWhitespace = canCollapseWhitespace;
|
|
631
|
+
}
|
|
632
|
+
if (!options.canTrimWhitespace) {
|
|
633
|
+
options.canTrimWhitespace = canTrimWhitespace;
|
|
636
634
|
}
|
|
637
635
|
|
|
638
636
|
if (!('ignoreCustomComments' in options)) {
|
|
@@ -676,23 +674,17 @@ function processOptions(options) {
|
|
|
676
674
|
if (typeof minifyJS !== 'object') {
|
|
677
675
|
minifyJS = {};
|
|
678
676
|
}
|
|
679
|
-
minifyJS.fromString = true;
|
|
680
677
|
(minifyJS.parse || (minifyJS.parse = {})).bare_returns = false;
|
|
681
678
|
options.minifyJS = function(text, inline) {
|
|
682
679
|
var start = text.match(/^\s*<!--.*/);
|
|
683
680
|
var code = start ? text.slice(start[0].length).replace(/\n\s*-->\s*$/, '') : text;
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
code = code.slice(0, -1);
|
|
689
|
-
}
|
|
690
|
-
return code;
|
|
691
|
-
}
|
|
692
|
-
catch (err) {
|
|
693
|
-
options.log(err);
|
|
681
|
+
minifyJS.parse.bare_returns = inline;
|
|
682
|
+
var result = UglifyJS.minify(code, minifyJS);
|
|
683
|
+
if (result.error) {
|
|
684
|
+
options.log(result.error);
|
|
694
685
|
return text;
|
|
695
686
|
}
|
|
687
|
+
return result.code.replace(/;$/, '');
|
|
696
688
|
};
|
|
697
689
|
}
|
|
698
690
|
|
|
@@ -760,7 +752,7 @@ function createSortFns(value, options, uidIgnore, uidAttr) {
|
|
|
760
752
|
for (var i = 0, len = attrs.length; i < len; i++) {
|
|
761
753
|
var attr = attrs[i];
|
|
762
754
|
if (classChain && (options.caseSensitive ? attr.name : attr.name.toLowerCase()) === 'class') {
|
|
763
|
-
classChain.add(trimWhitespace(attr.value).split(
|
|
755
|
+
classChain.add(trimWhitespace(attr.value).split(/[ \t\n\f\r]+/).filter(shouldSkipUIDs));
|
|
764
756
|
}
|
|
765
757
|
else if (options.processScripts && attr.name.toLowerCase() === 'type') {
|
|
766
758
|
currentTag = tag;
|
|
@@ -808,7 +800,7 @@ function createSortFns(value, options, uidIgnore, uidAttr) {
|
|
|
808
800
|
if (classChain) {
|
|
809
801
|
var sorter = classChain.createSorter();
|
|
810
802
|
options.sortClassName = function(value) {
|
|
811
|
-
return sorter.sort(value.split(
|
|
803
|
+
return sorter.sort(value.split(/[ \n\f\r]+/)).join(' ');
|
|
812
804
|
};
|
|
813
805
|
}
|
|
814
806
|
}
|
|
@@ -900,11 +892,11 @@ function minify(value, options, partialMarkup) {
|
|
|
900
892
|
}
|
|
901
893
|
|
|
902
894
|
function _canCollapseWhitespace(tag, attrs) {
|
|
903
|
-
return
|
|
895
|
+
return options.canCollapseWhitespace(tag, attrs, canCollapseWhitespace);
|
|
904
896
|
}
|
|
905
897
|
|
|
906
898
|
function _canTrimWhitespace(tag, attrs) {
|
|
907
|
-
return
|
|
899
|
+
return options.canTrimWhitespace(tag, attrs, canTrimWhitespace);
|
|
908
900
|
}
|
|
909
901
|
|
|
910
902
|
function removeStartTag() {
|
|
@@ -1006,10 +998,10 @@ function minify(value, options, partialMarkup) {
|
|
|
1006
998
|
if (!stackNoTrimWhitespace.length) {
|
|
1007
999
|
squashTrailingWhitespace(tag);
|
|
1008
1000
|
}
|
|
1009
|
-
if (!_canTrimWhitespace(tag, attrs)) {
|
|
1001
|
+
if (!_canTrimWhitespace(tag, attrs) || stackNoTrimWhitespace.length) {
|
|
1010
1002
|
stackNoTrimWhitespace.push(tag);
|
|
1011
1003
|
}
|
|
1012
|
-
if (!_canCollapseWhitespace(tag, attrs)) {
|
|
1004
|
+
if (!_canCollapseWhitespace(tag, attrs) || stackNoCollapseWhitespace.length) {
|
|
1013
1005
|
stackNoCollapseWhitespace.push(tag);
|
|
1014
1006
|
}
|
|
1015
1007
|
}
|