mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 12:20:04 +02:00
update minify
This commit is contained in:
25
node_modules/html-minifier/README.md
generated
vendored
25
node_modules/html-minifier/README.md
generated
vendored
@@ -20,19 +20,19 @@ How does HTMLMinifier compare to other solutions — [HTML Minifier from Will Pe
|
||||
|
||||
| Site | Original size *(KB)* | HTMLMinifier | minimize | Will Peavy | htmlcompressor.com |
|
||||
| ---------------------------------------------------------------------------- |:--------------------:| ------------:| --------:| ----------:| ------------------:|
|
||||
| [Google](https://www.google.com/) | 48 | **44** | 48 | 49 | 48 |
|
||||
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 154 | **117** | 128 | 133 | 128 |
|
||||
| [Twitter](https://twitter.com/) | 203 | **162** | 195 | 219 | 195 |
|
||||
| [Stack Overflow](https://stackoverflow.com/) | 254 | **196** | 208 | 216 | 205 |
|
||||
| [Bootstrap CSS](https://getbootstrap.com/docs/3.3/css/) | 271 | **260** | 269 | 229 | 269 |
|
||||
| [BBC](https://www.bbc.co.uk/) | 288 | **230** | 280 | 281 | 272 |
|
||||
| [Amazon](https://www.amazon.co.uk/) | 508 | **439** | 495 | 501 | n/a |
|
||||
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 533 | **434** | 517 | 536 | 517 |
|
||||
| [New York Times](https://mathiasbynens.be/_tmp/nyt.html) | 699 | **619** | 693 | 683 | n/a |
|
||||
| [NBC](https://www.nbc.com/) | 700 | **657** | 698 | 699 | n/a |
|
||||
| [Google](https://www.google.com/) | 46 | **42** | 46 | 48 | 46 |
|
||||
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 125 | **98** | 111 | 117 | 111 |
|
||||
| [Twitter](https://twitter.com/) | 207 | **165** | 200 | 224 | 200 |
|
||||
| [Stack Overflow](https://stackoverflow.com/) | 253 | **195** | 207 | 215 | 204 |
|
||||
| [Bootstrap CSS](https://getbootstrap.com/docs/3.3/css/) | 271 | **260** | 269 | 228 | 269 |
|
||||
| [BBC](https://www.bbc.co.uk/) | 298 | **239** | 290 | 291 | 280 |
|
||||
| [Amazon](https://www.amazon.co.uk/) | 422 | **316** | 412 | 425 | n/a |
|
||||
| [NBC](https://www.nbc.com/) | 553 | **530** | 552 | 553 | 534 |
|
||||
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 565 | **461** | 548 | 569 | 548 |
|
||||
| [New York Times](https://www.nytimes.com/) | 678 | **606** | 675 | 670 | n/a |
|
||||
| [Eloquent Javascript](https://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |
|
||||
| [ES6 table](https://kangax.github.io/compat-table/es6/) | 5308 | **4529** | 5025 | n/a | n/a |
|
||||
| [ES draft](https://tc39.github.io/ecma262/) | 6082 | **5456** | 5624 | n/a | n/a |
|
||||
| [ES6 table](https://kangax.github.io/compat-table/es6/) | 5911 | **5051** | 5595 | n/a | n/a |
|
||||
| [ES draft](https://tc39.github.io/ecma262/) | 6126 | **5495** | 5664 | n/a | n/a |
|
||||
|
||||
## Options Quick Reference
|
||||
|
||||
@@ -45,6 +45,7 @@ Most of the options are disabled by default.
|
||||
| `collapseInlineTagWhitespace` | Don't leave any spaces between `display:inline;` elements when collapsing. Must be used in conjunction with `collapseWhitespace=true` | `false` |
|
||||
| `collapseWhitespace` | [Collapse white space that contributes to text nodes in a document tree](http://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace) | `false` |
|
||||
| `conservativeCollapse` | Always collapse to 1 space (never remove it entirely). Must be used in conjunction with `collapseWhitespace=true` | `false` |
|
||||
| `continueOnParseError` | [Handle parse errors](https://html.spec.whatwg.org/multipage/parsing.html#parse-errors) instead of aborting. | `false` |
|
||||
| `customAttrAssign` | Arrays of regex'es that allow to support custom attribute assign expressions (e.g. `'<div flex?="{{mode != cover}}"></div>'`) | `[ ]` |
|
||||
| `customAttrCollapse` | Regex that specifies custom attribute to strip newlines from (e.g. `/ng-class/`) | |
|
||||
| `customAttrSurround` | Arrays of regex'es that allow to support custom attribute surround expressions (e.g. `<input {{#if value}}checked="checked"{{/if}}>`) | `[ ]` |
|
||||
|
1
node_modules/html-minifier/cli.js
generated
vendored
Normal file → Executable file
1
node_modules/html-minifier/cli.js
generated
vendored
Normal file → Executable file
@@ -103,6 +103,7 @@ var mainOptions = {
|
||||
collapseInlineTagWhitespace: 'Collapse white space around inline tag',
|
||||
collapseWhitespace: 'Collapse white space that contributes to text nodes in a document tree.',
|
||||
conservativeCollapse: 'Always collapse to 1 space (never remove it entirely)',
|
||||
continueOnParseError: 'Handle parse errors instead of aborting',
|
||||
customAttrAssign: ['Arrays of regex\'es that allow to support custom attribute assign expressions (e.g. \'<div flex?="{{mode != cover}}"></div>\')', parseJSONRegExpArray],
|
||||
customAttrCollapse: ['Regex that specifies custom attribute to strip newlines from (e.g. /ng-class/)', parseRegExp],
|
||||
customAttrSurround: ['Arrays of regex\'es that allow to support custom attribute surround expressions (e.g. <input {{#if value}}checked="checked"{{/if}}>)', parseJSONRegExpArray],
|
||||
|
64
node_modules/html-minifier/package.json
generated
vendored
64
node_modules/html-minifier/package.json
generated
vendored
@@ -1,40 +1,40 @@
|
||||
{
|
||||
"_from": "html-minifier@^3.0.1",
|
||||
"_id": "html-minifier@3.5.21",
|
||||
"_from": "html-minifier@^4.0.0",
|
||||
"_id": "html-minifier@4.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-LKUKwuJDhxNa3uf/LPR/KVjm/l3rBqtYeCOAekvG8F1vItxMUpueGd94i/asDDr8/1u7InxzFA5EeGjhhG5mMA==",
|
||||
"_integrity": "sha512-aoGxanpFPLg7MkIl/DDFYtb0iWz7jMFGqFhvEDZga6/4QTjneiD8I/NXL1x5aaoCp7FSIT6h/OhykDdPsbtMig==",
|
||||
"_location": "/html-minifier",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "html-minifier@^3.0.1",
|
||||
"raw": "html-minifier@^4.0.0",
|
||||
"name": "html-minifier",
|
||||
"escapedName": "html-minifier",
|
||||
"rawSpec": "^3.0.1",
|
||||
"rawSpec": "^4.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^3.0.1"
|
||||
"fetchSpec": "^4.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/minify"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.21.tgz",
|
||||
"_shasum": "d0040e054730e354db008463593194015212d20c",
|
||||
"_spec": "html-minifier@^3.0.1",
|
||||
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\minify",
|
||||
"_resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-4.0.0.tgz",
|
||||
"_shasum": "cca9aad8bce1175e02e17a8c33e46d8988889f56",
|
||||
"_spec": "html-minifier@^4.0.0",
|
||||
"_where": "/home/s2/Code/minifyfromhtml/node_modules/minify",
|
||||
"author": {
|
||||
"name": "Juriy \"kangax\" Zaytsev"
|
||||
},
|
||||
"benchmarkDependencies": {
|
||||
"brotli": "1.3.x",
|
||||
"chalk": "2.4.x",
|
||||
"cli-table": "0.3.x",
|
||||
"lzma": "2.3.x",
|
||||
"minimize": "2.2.x",
|
||||
"progress": "2.0.x"
|
||||
"brotli": "^1.3.2",
|
||||
"chalk": "^2.4.2",
|
||||
"cli-table": "^0.3.1",
|
||||
"lzma": "^2.3.2",
|
||||
"minimize": "^2.2.0",
|
||||
"progress": "^2.0.3"
|
||||
},
|
||||
"bin": {
|
||||
"html-minifier": "./cli.js"
|
||||
"html-minifier": "cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kangax/html-minifier/issues"
|
||||
@@ -55,26 +55,26 @@
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"camel-case": "3.0.x",
|
||||
"clean-css": "4.2.x",
|
||||
"commander": "2.17.x",
|
||||
"he": "1.2.x",
|
||||
"param-case": "2.1.x",
|
||||
"relateurl": "0.2.x",
|
||||
"uglify-js": "3.4.x"
|
||||
"camel-case": "^3.0.0",
|
||||
"clean-css": "^4.2.1",
|
||||
"commander": "^2.19.0",
|
||||
"he": "^1.2.0",
|
||||
"param-case": "^2.1.1",
|
||||
"relateurl": "^0.2.7",
|
||||
"uglify-js": "^3.5.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
|
||||
"devDependencies": {
|
||||
"grunt": "1.0.x",
|
||||
"grunt-browserify": "5.3.x",
|
||||
"grunt-contrib-uglify": "3.4.x",
|
||||
"gruntify-eslint": "4.0.x",
|
||||
"phantomjs-prebuilt": "2.1.x",
|
||||
"qunit": "2.x"
|
||||
"grunt": "^1.0.4",
|
||||
"grunt-browserify": "^5.3.0",
|
||||
"grunt-contrib-uglify": "^4.0.1",
|
||||
"grunt-eslint": "^21.0.0",
|
||||
"phantomjs-prebuilt": "^2.1.16",
|
||||
"qunit": "^2.9.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"src/*.js",
|
||||
@@ -125,5 +125,5 @@
|
||||
"dist": "grunt dist",
|
||||
"test": "grunt test"
|
||||
},
|
||||
"version": "3.5.21"
|
||||
"version": "4.0.0"
|
||||
}
|
||||
|
1
node_modules/html-minifier/sample-cli-config-file.conf
generated
vendored
1
node_modules/html-minifier/sample-cli-config-file.conf
generated
vendored
@@ -4,6 +4,7 @@
|
||||
"collapseInlineTagWhitespace": false,
|
||||
"collapseWhitespace": true,
|
||||
"conservativeCollapse": false,
|
||||
"continueOnParseError": true,
|
||||
"customAttrCollapse": ".*",
|
||||
"decodeEntities": true,
|
||||
"html5": true,
|
||||
|
31
node_modules/html-minifier/src/htmlminifier.js
generated
vendored
31
node_modules/html-minifier/src/htmlminifier.js
generated
vendored
@@ -311,6 +311,9 @@ function cleanAttributeValue(tag, attrName, attrValue, options, attrs) {
|
||||
return (+numString).toString();
|
||||
});
|
||||
}
|
||||
else if (isContentSecurityPolicy(tag, attrs) && attrName.toLowerCase() === 'content') {
|
||||
return collapseWhitespaceAll(attrValue);
|
||||
}
|
||||
else if (options.customAttrCollapse && options.customAttrCollapse.test(attrName)) {
|
||||
attrValue = attrValue.replace(/\n+|\r+|\s{2,}/g, '');
|
||||
}
|
||||
@@ -335,6 +338,17 @@ function isMetaViewport(tag, attrs) {
|
||||
}
|
||||
}
|
||||
|
||||
function isContentSecurityPolicy(tag, attrs) {
|
||||
if (tag !== 'meta') {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0, len = attrs.length; i < len; i++) {
|
||||
if (attrs[i].name.toLowerCase() === 'http-equiv' && attrs[i].value.toLowerCase() === 'content-security-policy') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ignoreCSS(id) {
|
||||
return '/* clean-css ignore:start */' + id + '/* clean-css ignore:end */';
|
||||
}
|
||||
@@ -864,19 +878,19 @@ function minify(value, options, partialMarkup) {
|
||||
value = value.replace(reCustomIgnore, function(match) {
|
||||
if (!uidAttr) {
|
||||
uidAttr = uniqueId(value);
|
||||
uidPattern = new RegExp('(\\s*)' + uidAttr + '([0-9]+)(\\s*)', 'g');
|
||||
uidPattern = new RegExp('(\\s*)' + uidAttr + '([0-9]+)' + uidAttr + '(\\s*)', 'g');
|
||||
if (options.minifyCSS) {
|
||||
options.minifyCSS = (function(fn) {
|
||||
return function(text, type) {
|
||||
text = text.replace(uidPattern, function(match, prefix, index) {
|
||||
var chunks = ignoredCustomMarkupChunks[+index];
|
||||
return chunks[1] + uidAttr + index + chunks[2];
|
||||
return chunks[1] + uidAttr + index + uidAttr + chunks[2];
|
||||
});
|
||||
var ids = [];
|
||||
new CleanCSS().minify(wrapCSS(text, type)).warnings.forEach(function(warning) {
|
||||
var match = uidPattern.exec(warning);
|
||||
if (match) {
|
||||
var id = uidAttr + match[2];
|
||||
var id = uidAttr + match[2] + uidAttr;
|
||||
text = text.replace(id, ignoreCSS(id));
|
||||
ids.push(id);
|
||||
}
|
||||
@@ -894,13 +908,13 @@ function minify(value, options, partialMarkup) {
|
||||
return function(text, type) {
|
||||
return fn(text.replace(uidPattern, function(match, prefix, index) {
|
||||
var chunks = ignoredCustomMarkupChunks[+index];
|
||||
return chunks[1] + uidAttr + index + chunks[2];
|
||||
return chunks[1] + uidAttr + index + uidAttr + chunks[2];
|
||||
}), type);
|
||||
};
|
||||
})(options.minifyJS);
|
||||
}
|
||||
}
|
||||
var token = uidAttr + ignoredCustomMarkupChunks.length;
|
||||
var token = uidAttr + ignoredCustomMarkupChunks.length + uidAttr;
|
||||
ignoredCustomMarkupChunks.push(/^(\s*)[\s\S]*?(\s*)$/.exec(match));
|
||||
return '\t' + token + '\t';
|
||||
});
|
||||
@@ -965,6 +979,9 @@ function minify(value, options, partialMarkup) {
|
||||
|
||||
new HTMLParser(value, {
|
||||
partialMarkup: partialMarkup,
|
||||
continueOnParseError: options.continueOnParseError,
|
||||
customAttrAssign: options.customAttrAssign,
|
||||
customAttrSurround: options.customAttrSurround,
|
||||
html5: options.html5,
|
||||
|
||||
start: function(tag, attrs, unary, unarySlash, autoGenerated) {
|
||||
@@ -1241,9 +1258,7 @@ function minify(value, options, partialMarkup) {
|
||||
buffer.push(options.useShortDoctype ? '<!doctype' +
|
||||
(options.removeTagWhitespace ? '' : ' ') + 'html>' :
|
||||
collapseWhitespaceAll(doctype));
|
||||
},
|
||||
customAttrAssign: options.customAttrAssign,
|
||||
customAttrSurround: options.customAttrSurround
|
||||
}
|
||||
});
|
||||
|
||||
if (options.removeOptionalTags) {
|
||||
|
6
node_modules/html-minifier/src/htmlparser.js
generated
vendored
6
node_modules/html-minifier/src/htmlparser.js
generated
vendored
@@ -182,6 +182,11 @@ function HTMLParser(html, handler) {
|
||||
prevTag = startTagMatch.tagName.toLowerCase();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Treat `<` as text
|
||||
if (handler.continueOnParseError) {
|
||||
textEnd = html.indexOf('<', 1);
|
||||
}
|
||||
}
|
||||
|
||||
var text;
|
||||
@@ -213,7 +218,6 @@ function HTMLParser(html, handler) {
|
||||
handler.chars(text, prevTag, nextTag);
|
||||
}
|
||||
prevTag = '';
|
||||
|
||||
}
|
||||
else {
|
||||
var stackedTag = lastTag.toLowerCase();
|
||||
|
Reference in New Issue
Block a user