https://github.com/kangax/html-minifier#options-quick-reference
1、參數列表
| option | Description | Default |
| removeComments | 刪除注釋,但是會保留script和style中的注釋 | false |
| removeCommentsFromCDATA | 從腳本和樣式刪除的注釋 | false |
| removeCDATASectionsFromCDATA | 刪除CDATA節從腳本和樣式元素 | |
| collapseWhitespace | 刪除空格,但是不會刪除SCRIPT、style和textarea中的空格 | |
| conservativeCollapse | 刪除空格,總是保留一個空格 | |
| preserveLineBreaks | ||
| collapseBooleanAttributes | 省略只有boolean值的屬性值,比如:readonly checked | |
| removeAttributeQuotes | 刪除引號,刪除不需要引號的值。 例如: var input = '<p class="foo-bar" id="moo" title="blah blah">foo</p>'; var output = minify(input, { removeAttributeQuotes: true }); output; // '<p class="foo-bar" id=moo title="blah blah">foo</p>' |
|
| removeRedundantAttributes | 刪除多余的屬性 | |
| preventAttributesEscaping | ||
| useShortDoctype | 使用短的文檔類型 | |
| removeEmptyAttributes | 刪除空屬性 | |
| removeScriptTypeAttributes | 刪除script的類型屬性,在h5下面script的type默認值:text/javascript | |
| removeStyleLinkTypeAttributes | 刪除style的類型屬性,同上 | |
| removeOptionalTags | ||
| removeIgnored | 刪除指定開頭和結尾的內容 以逗號分割 | |
| removeEmptyElements | 刪除空元素 | |
| lint | ||
| keepClosingSlash | ||
| caseSensitive | ||
| minifyJS | 壓縮js | |
| minifyCSS | 壓縮css | |
| minifyURLs | 壓縮url | |
| ignoreCustomComments | 忽略指定的注釋內容 | |
| processScripts | ||
| maxLineLength | 指定html輸出的最大列數,超過就換行顯示 | |
| customAttrAssign | 允許的自定義屬性列表 | |
| customAttrSurround | ||
| customAttrCollapse | 指定要換行的自定義屬性(正則) |
更多可以參考作者例子:
http://perfectionkills.com/experimenting-with-html-minifier/
注:通過自己驗證然后結合翻譯總結的描述,有錯誤的地方請指正,謝謝!
