html-minifier man page

html-minifier — HTML minifier with lint-like capabilities


html-minifier [Options] [FILE(s)]


HTMLMinifier is a highly configurable, well-tested, Javascript-based HTML minifier, with lint-like capabilities.


If no input file(s) specified then STDIN will be used for input.

If more than one input file specified those will be concatenated and minified together.

When you specify a config file with the --config-file option (see /usr/share/doc/nodejs-html-minifier/sample-cli-config-file.conf for format) you can still override some of its contents by providing individual command line options, too.

When you want to provide an array of strings for --ignore-custom-comments or --process-scripts options on the command line you must escape those such as --ignore-custom-comments "[\"string1\",\"string1\"]"


-v, --version
Version information
-o, --output FILE
Specify output file (if not specified STDOUT will be used for output)
-c, --config-file FILE
Use config file
Strip HTML comments
Strip HTML comments from scripts and styles
Remove CDATA sections from script and style elements
Collapse white space that contributes to text nodes in a document tree.
Always collapse to 1 space (never remove it entirely)
Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break.
Omit attribute values from boolean attributes
Remove quotes around attributes when possible.
Remove attributes when value matches default.
Replaces the doctype with the short (HTML5) doctype
Remove all attributes with whitespace-only values
Remove unrequired tags
Remove all elements with empty contents
Toggle linting
Keep the trailing slash on singleton elements
Treat attributes in case sensitive manner (useful for SVG; e.g. viewBox)
Minify Javascript in script elements and on* attributes (uses UglifyJS)
Minify CSS in style elements and style attributes (uses clean-css)
Minify URLs in various attributes (uses relateurl)
--ignore-custom-comments STRING
Array of regex'es that allow to ignore certain comments, when matched
--process-scripts STRING
Array of strings corresponding to types of script elements to process through minifier (e.g. "text/ng-template", "text/x-handlebars-template", etc.)
--max-line-length NUMBER
Max line length
-h, --help
Display help and usage details


html-minifier December 2014