I have HTML in a variable and before render it and I want to minify it. I know there are console minifiers such as:
But I want to
The module you specified, html-minifier, already does what you're asking for. This is how it's used:
var minify = require('html-minifier').minify;
var input = 'baz';
var output = minify(input, options);
The options object requires at least one of the boolean flags shown below. If no flags are specified, the minifier will just return the string that was passed in as input.
removeComments
removeCommentsFromCDATA
collapseWhitespace
collapseBooleanAttributes
removeAttributeQuotes
removeRedundantAttributes
useShortDoctype
removeEmptyAttributes
removeOptionalTags
removeEmptyElements
Note that the library parses the input as HTML, not XHTML.