HTMLMinifier (html-minifier) (3.5.14) for Node.js (v8.11.1), installed with npm install html-minifier -g
, can be run via command line (Windows CMD), e.g. html-minifier --help
produces the usage info (excerpts):
Usage: html-minifier [options] [files...]
Options:
-V, --version output the version number
...
--minify-js [value] Minify Javascript in script elements and on* attributes (uses uglify-js)
...
-c --config-file <file> Use config file
--input-dir <dir> Specify an input directory
--output-dir <dir> Specify an output directory
--file-ext <text> Specify an extension to be read, ex: html
-h, --help output usage information
The option --minify-js [value]
relies on UglifyJS to "compress" the JavaScript embedded inside the HTML file(s) passed to html-minifier
. UglifyJS can remove console.log()
function calls (Can uglify-js remove the console.log statements?) from the JavaScript, by enabling the drop_console
option (also see pure_funcs
).
But --minify-js drop_console=true
does not have an effect, nor does something like "uglify:{options:{compress:{drop_console:true}}}"
or "compress:{pure_funcs:['console.log']}"
.
How can such an option be set, ideally via the html-minifier command line (alternatively by config-file, though it just sets "minifyJS": true
)?