| `includeAutoGeneratedTags` | Insert tags generated by HTML parser | `true` |
| `keepClosingSlash` | Keep the trailing slash on singleton elements | `false` |
| `maxLineLength` | Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points |
-| `minifyCSS` | Minify CSS in style elements and style attributes (uses [clean-css](https://github.com/jakubpawlowicz/clean-css)). `advanced` optimisations are disabled by default | `false` (could be `true`, `Object`, `Function(text)`) |
+| `minifyCSS` | Minify CSS in style elements and style attributes (uses [clean-css](https://github.com/jakubpawlowicz/clean-css)) | `false` (could be `true`, `Object`, `Function(text)`) |
| `minifyJS` | Minify JavaScript in script elements and event attributes (uses [UglifyJS](https://github.com/mishoo/UglifyJS2)) | `false` (could be `true`, `Object`, `Function(text, inline)`) |
| `minifyURLs` | Minify URLs in various attributes (uses [relateurl](https://github.com/stevenvachon/relateurl)) | `false` (could be `String`, `Object`, `Function(text)`) |
| `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` |
input = '<style>p.h{background:red}<!--\np.i{background:red}\n-->p.j{background:red}</style>';
assert.equal(minify(input), input);
- output = '<style>p.h{background:red}<!-- p.i{background:red}-->p.j{background:red}</style>';
+ output = '<style>p.h{background:red}p.i{background:red}p.j{background:red}</style>';
assert.equal(minify(input, { minifyCSS: true }), output);
input = '<style type="text/css"><!-- p { color: red } --></style>';
input = '<style><![CDATA[\np.a{background:red}\n]]></style>';
assert.equal(minify(input), input);
- output = '<style><![CDATA[ p.a{background:red}\n]]></style>';
+ output = '<style></style>';
assert.equal(minify(input, { minifyCSS: true }), output);
input = '<style><![CDATA[p.b{background:red}]]></style>';
assert.equal(minify(input), input);
- output = '<style><![CDATA[p.b{background:red}]]></style>';
+ output = '<style></style>';
assert.equal(minify(input, { minifyCSS: true }), output);
input = '<style><![CDATA[p.c{background:red}\n]]></style>';
assert.equal(minify(input), input);
- output = '<style><![CDATA[p.c{background:red}\n]]></style>';
+ output = '<style></style>';
assert.equal(minify(input, { minifyCSS: true }), output);
input = '<style><![CDATA[\np.d{background:red}]]></style>';
assert.equal(minify(input), input);
- output = '<style><![CDATA[ p.d{background:red}]]></style>';
+ output = '<style></style>';
assert.equal(minify(input, { minifyCSS: true }), output);
input = '<style><![CDATA[p.e{background:red}\np.f{background:red}\np.g{background:red}]]></style>';
assert.equal(minify(input), input);
- output = '<style><![CDATA[p.e{background:red}p.f{background:red}p.g{background:red}]]></style>';
+ output = '<style>p.f{background:red}p.g{background:red}</style>';
assert.equal(minify(input, { minifyCSS: true }), output);
input = '<style>p.h{background:red}<![CDATA[\np.i{background:red}\n]]>p.j{background:red}</style>';
assert.equal(minify(input), input);
- output = '<style>p.h{background:red}<![CDATA[ p.i{background:red}]]>p.j{background:red}</style>';
+ output = '<style>p.h{background:red}]]>p.j{background:red}</style>';
assert.equal(minify(input, { minifyCSS: true }), output);
input = '<style>/* <![CDATA[ */p { color: red } // ]]></style>';
assert.equal(minify(input), input);
- output = '<style>p{color:red} // ]]></style>';
+ output = '<style>p{color:red}</style>';
assert.equal(minify(input, { minifyCSS: true }), output);
input = '<style type="text/html">\n<div>\n</div>\n<![CDATA[ aa ]]>\n</style>';
minifyURLs: { site: 'http://website.com/foo bar/' }
}), output);
+ input = '<style>body { background: url("http://website.com/foo bar/(baz)/bg.png") }</style>';
+ assert.equal(minify(input, { minifyURLs: { site: 'http://website.com/' } }), input);
+ assert.equal(minify(input, { minifyURLs: { site: 'http://website.com/foo%20bar/' } }), input);
+ assert.equal(minify(input, { minifyURLs: { site: 'http://website.com/foo%20bar/(baz)/' } }), input);
+ output = '<style>body{background:url("foo%20bar/(baz)/bg.png")}</style>';
+ assert.equal(minify(input, {
+ minifyCSS: true,
+ minifyURLs: { site: 'http://website.com/' }
+ }), output);
+ output = '<style>body{background:url("(baz)/bg.png")}</style>';
+ assert.equal(minify(input, {
+ minifyCSS: true,
+ minifyURLs: { site: 'http://website.com/foo%20bar/' }
+ }), output);
+ output = '<style>body{background:url(bg.png)}</style>';
+ assert.equal(minify(input, {
+ minifyCSS: true,
+ minifyURLs: { site: 'http://website.com/foo%20bar/(baz)/' }
+ }), output);
+
input = '<img src="http://cdn.site.com/foo.png">';
output = '<img src="//cdn.site.com/foo.png">';
assert.equal(minify(input, { minifyURLs: { site: 'http://site.com/' } }), output);