html-minifier 1.4.0 → 1.5.0

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
@@ -23,53 +23,61 @@ How does HTMLMinifier compare to other solutions — [HTML Minifier from Will Pe
23
23
  | [HTMLMinifier page](https://github.com/kangax/html-minifier) | 49 | **37** | 42 | 44 | 43 |
24
24
  | [NBC](http://www.nbc.com/) | 91 | **74** | 84 | 85 | 85 |
25
25
  | [ES6 table](http://kangax.github.io/es5-compat-table/es6/) | 118 | **80** | 93 | 93 | 94 |
26
- | [New York Times](http://www.nytimes.com/) | 131 | **101** | 122 | 125 | 120 |
26
+ | [New York Times](http://www.nytimes.com/) | 131 | **100** | 122 | 125 | 120 |
27
27
  | [Google](https://www.google.com/) | 133 | **128** | 132 | 135 | 131 |
28
- | [MSN](http://www.msn.com/) | 157 | **130** | 138 | 145 | 138 |
29
- | [Stackoverflow](http://stackoverflow.com/) | 200 | **159** | 165 | 173 | 166 |
28
+ | [MSN](http://www.msn.com/) | 157 | **127** | 138 | 145 | 138 |
29
+ | [Stackoverflow](http://stackoverflow.com/) | 200 | **156** | 165 | 173 | 166 |
30
30
  | [Amazon](http://www.amazon.com/) | 246 | **203** | 234 | 230 | 219 |
31
- | [Bootstrap CSS](http://getbootstrap.com/css/) | 277 | **268** | 274 | 232 | 277 |
32
- | [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 401 | **367** | 388 | 400 | n/a |
33
- | [Eloquent Javascript](http://eloquentjavascript.net/1st_edition/print.html) | 870 | **827** | 840 | 864 | n/a |
34
- | [ES6 draft](https://tc39.github.io/ecma262/) | 3678 | **2991** | 3079 | 3183 | n/a |
31
+ | [Bootstrap CSS](http://getbootstrap.com/css/) | 277 | **264** | 274 | 232 | 277 |
32
+ | [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 401 | **364** | 388 | 400 | n/a |
33
+ | [Eloquent Javascript](http://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |
34
+ | [ES6 draft](https://tc39.github.io/ecma262/) | 3678 | **2980** | 3079 | 3183 | n/a |
35
35
 
36
36
  ## Options Quick Reference
37
37
 
38
38
  | Option | Description | Default |
39
39
  |--------------------------------|-----------------|---------|
40
- | `removeComments` | [Strip HTML comments](http://perfectionkills.com/experimenting-with-html-minifier/#remove_comments) | `false` |
41
- | `collapseWhitespace` | [Collapse white space that contributes to text nodes in a document tree.](http://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace) | `false` |
42
- | `conservativeCollapse` | Always collapse to 1 space (never remove it entirely). Must be used in conjunction with `collapseWhitespace=true` | `false` |
43
- | `collapseInlineTagWhitespace` | Don't leave any spaces between `display:inline;` elements when collapsing. Must be used in conjunction with `collapseWhitespace=true` | `false` |
44
- | `preserveLineBreaks` | Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. Must be used in conjunction with `collapseWhitespace=true` | `false` |
40
+ | `caseSensitive` | Treat attributes in case sensitive manner (useful for custom HTML tags) | `false` |
45
41
  | `collapseBooleanAttributes` | [Omit attribute values from boolean attributes](http://perfectionkills.com/experimenting-with-html-minifier/#collapse_boolean_attributes) | `false` |
46
- | `removeTagWhitespace` | Remove space between attributes whenever possible. **Note that this will result in invalid HTML!** | `false` |
47
- | `removeAttributeQuotes` | [Remove quotes around attributes when possible.](http://perfectionkills.com/experimenting-with-html-minifier/#remove_attribute_quotes) | `false` |
48
- | `removeRedundantAttributes` | [Remove attributes when value matches default.](http://perfectionkills.com/experimenting-with-html-minifier/#remove_redundant_attributes) | `false` |
49
- | `preventAttributesEscaping` | Prevents the escaping of the values of attributes. | `false` |
50
- | `useShortDoctype` | [Replaces the `doctype` with the short (HTML5) doctype](http://perfectionkills.com/experimenting-with-html-minifier/#use_short_doctype) | `false` |
51
- | `removeEmptyAttributes` | [Remove all attributes with whitespace-only values](http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_or_blank_attributes) | `false` |
52
- | `removeScriptTypeAttributes` | Remove `type="text/javascript"` from `script` tags. Other `type` attribute values are left intact. | `false` |
53
- | `removeStyleLinkTypeAttributes`| Remove `type="text/css"` from `style` and `link` tags. Other `type` attribute values are left intact. | `false` |
54
- | `removeOptionalTags` | [Remove optional tags](http://perfectionkills.com/experimenting-with-html-minifier/#remove_optional_tags) | `false` |
55
- | `removeEmptyElements` | [Remove all elements with empty contents](http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_elements) | `false` |
42
+ | `collapseInlineTagWhitespace` | Don't leave any spaces between `display:inline;` elements when collapsing. Must be used in conjunction with `collapseWhitespace=true` | `false` |
43
+ | `collapseWhitespace` | [Collapse white space that contributes to text nodes in a document tree](http://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace) | `false` |
44
+ | `conservativeCollapse` | Always collapse to 1 space (never remove it entirely). Must be used in conjunction with `collapseWhitespace=true` | `false` |
45
+ | `customAttrAssign` | Arrays of regex'es that allow to support custom attribute assign expressions (e.g. `'<div flex?="{{mode != cover}}"></div>'`) | `[ ]` |
46
+ | `customAttrCollapse` | Regex that specifies custom attribute to strip newlines from (e.g. `/ng-class/`) | |
47
+ | `customAttrSurround` | Arrays of regex'es that allow to support custom attribute surround expressions (e.g. `<input {{#if value}}checked="checked"{{/if}}>`) | `[ ]` |
48
+ | `customEventAttributes` | Arrays of regex'es that allow to support custom event attributes for `minifyJS` (e.g. `ng-click`) | `[ /^on[a-z]{3,}$/ ]` |
49
+ | `decodeEntities` | Use direct Unicode characters whenever possible | `false` |
50
+ | `html5` | Parse input according to HTML5 specifications | `true` |
51
+ | `ignoreCustomComments` | Array of regex'es that allow to ignore certain comments, when matched | `[ ]` |
52
+ | `ignoreCustomFragments` | Array of regex'es that allow to ignore certain fragments, when matched (e.g. `<?php ... ?>`, `{{ ... }}`, etc.) | `[ /<%[\s\S]*?%>/, /<\?[\s\S]*?\?>/ ]` |
53
+ | `includeAutoGeneratedTags` | Insert tags generated by HTML parser | `true` |
54
+ | `keepClosingSlash` | Keep the trailing slash on singleton elements | `false` |
56
55
  | `lint` | [Toggle linting](http://perfectionkills.com/experimenting-with-html-minifier/#validate_input_through_html_lint) | `false` |
57
- | `keepClosingSlash` | Keep the trailing slash on singleton elements | `false` |
58
- | `caseSensitive` | Treat attributes in case sensitive manner (useful for custom HTML tags.) | `false` |
59
- | `minifyJS` | Minify JavaScript in script elements and event attributes (uses [UglifyJS](https://github.com/mishoo/UglifyJS2)) | `false` (could be `true`, `false`, `Object` (options)) |
56
+ | `maxLineLength` | Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points |
60
57
  | `minifyCSS` | Minify CSS in style elements and style attributes (uses [clean-css](https://github.com/jakubpawlowicz/clean-css)) | `false` (could be `true`, `false`, `Object` (options)) |
58
+ | `minifyJS` | Minify JavaScript in script elements and event attributes (uses [UglifyJS](https://github.com/mishoo/UglifyJS2)) | `false` (could be `true`, `false`, `Object` (options)) |
61
59
  | `minifyURLs` | Minify URLs in various attributes (uses [relateurl](https://github.com/stevenvachon/relateurl)) | `false` (could be `Object` (options)) |
62
- | `includeAutoGeneratedTags` | Insert tags generated by HTML parser | `true` |
63
- | `ignoreCustomComments` | Array of regex'es that allow to ignore certain comments, when matched | `[ ]` |
64
- | `ignoreCustomFragments` | Array of regex'es that allow to ignore certain fragments, when matched (e.g. `<?php ... ?>`, `{{ ... }}`, etc.) | `[ /<%[\s\S]*?%>/, /<\?[\s\S]*?\?>/ ]` |
65
- | `processScripts` | Array of strings corresponding to types of script elements to process through minifier (e.g. `text/ng-template`, `text/x-handlebars-template`, etc.) | `[ ]` |
60
+ | `preserveLineBreaks` | Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. Must be used in conjunction with `collapseWhitespace=true` | `false` |
61
+ | `preventAttributesEscaping` | Prevents the escaping of the values of attributes | `false` |
66
62
  | `processConditionalComments` | Process contents of conditional comments through minifier | `false` |
67
- | `maxLineLength` | Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points. |
68
- | `customEventAttributes` | Arrays of regex'es that allow to support custom event attributes for `minifyJS` (e.g. `ng-click`) | `[ /^on[a-z]{3,}$/ ]` |
69
- | `customAttrAssign` | Arrays of regex'es that allow to support custom attribute assign expressions (e.g. `'<div flex?="{{mode != cover}}"></div>'`) | `[ ]` |
70
- | `customAttrSurround` | Arrays of regex'es that allow to support custom attribute surround expressions (e.g. `<input {{#if value}}checked="checked"{{/if}}>`) | `[ ]` |
71
- | `customAttrCollapse` | Regex that specifies custom attribute to strip newlines from (e.g. `/ng\-class/`) | |
63
+ | `processScripts` | Array of strings corresponding to types of script elements to process through minifier (e.g. `text/ng-template`, `text/x-handlebars-template`, etc.) | `[ ]` |
72
64
  | `quoteCharacter` | Type of quote to use for attribute values (' or ") | |
65
+ | `removeAttributeQuotes` | [Remove quotes around attributes when possible](http://perfectionkills.com/experimenting-with-html-minifier/#remove_attribute_quotes) | `false` |
66
+ | `removeComments` | [Strip HTML comments](http://perfectionkills.com/experimenting-with-html-minifier/#remove_comments) | `false` |
67
+ | `removeEmptyAttributes` | [Remove all attributes with whitespace-only values](http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_or_blank_attributes) | `false` |
68
+ | `removeEmptyElements` | [Remove all elements with empty contents](http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_elements) | `false` |
69
+ | `removeOptionalTags` | [Remove optional tags](http://perfectionkills.com/experimenting-with-html-minifier/#remove_optional_tags) | `false` |
70
+ | `removeRedundantAttributes` | [Remove attributes when value matches default.](http://perfectionkills.com/experimenting-with-html-minifier/#remove_redundant_attributes) | `false` |
71
+ | `removeScriptTypeAttributes` | Remove `type="text/javascript"` from `script` tags. Other `type` attribute values are left intact | `false` |
72
+ | `removeStyleLinkTypeAttributes`| Remove `type="text/css"` from `style` and `link` tags. Other `type` attribute values are left intact | `false` |
73
+ | `removeTagWhitespace` | Remove space between attributes whenever possible. **Note that this will result in invalid HTML!** | `false` |
74
+ | `sortAttributes` | [Sort attributes by frequency](#sorting-attributes--style-classes) | `false` |
75
+ | `sortClassName` | [Sort style classes by frequency](#sorting-attributes--style-classes) | `false` |
76
+ | `useShortDoctype` | [Replaces the `doctype` with the short (HTML5) doctype](http://perfectionkills.com/experimenting-with-html-minifier/#use_short_doctype) | `false` |
77
+
78
+ ### Sorting attributes / style classes
79
+
80
+ Minifier options like `sortAttributes` and `sortClassName` won't impact the plain-text size of the output. However, they form long repetitive chains of characters that should improve compression ratio of gzip used in HTTP compression.
73
81
 
74
82
  ## Special cases
75
83