DOKK / manpages / debian 12 / htmlmin / htmlmin.1.en
HTMLMIN(1) User Commands HTMLMIN(1)

htmlmin - htmlmin is a configurable HTML Minifier with safety features.

usage: htmlmin [-h] [-c] [-s] [--remove-all-empty-space]

[--keep-optional-attribute-quotes] [-H] [-k] [-a PRE_ATTR] [-p [TAG ...]] [-e ENCODING] [INPUT] [OUTPUT]

Minify HTML

File path to html file to minify. Defaults to stdin.
File path to output to. Defaults to stdout.

show this help message and exit
When set, comments will be removed. They can be kept on an individual basis by starting them with a '!': <!--! comment -->. The '!' will be removed from the final output. If you want a '!' as the leading character of your comment, put two of them: <!--!! comment -->.
When set, this removes empty space betwen tags in certain cases. Specifically, it will remove empty space if and only if there a newline character occurs within the space. Thus, code like '<span>x</span> <span>y</span>' will be left alone, but code such as ' ...
</head>
<body>
...'
will become '...</head><body>...'. Note that this CAN break your html if you spread two inline tags over two lines. Use with caution.
When set, this removes ALL empty space betwen tags. WARNING: this can and likely will cause unintended consequences. For instance, '<i>X</i> <i>Y</i>' will become '<i>X</i><i>Y</i>'. Putting whitespace along with other text will avoid this problem. Only use if you are confident in the result. Whitespace is not removed from inside of tags, thus '<span> </span>' will be left alone.
When set, this keeps all attribute quotes, even if they are optional.
If you are parsing only a fragment of HTML, and the fragment occurs in the head of the document, setting this will remove some extra whitespace.
HTMLMin supports the propietary attribute 'pre' that can be added to elements to prevent minification. This attribute is removed by default. Set this flag to keep the 'pre' attributes in place.
The attribute htmlmin looks for to find blocks of HTML that it should not minify. This attribute will be removed from the HTML unless '-k' is specified. Defaults to 'pre'.
By default, the contents of 'pre', and 'textarea' tags are left unminified. You can specify different tags using the --pre-tags option. 'script' and 'style' tags are always left unmininfied.
Encoding to read and write with. Default 'utf-8'. When reading from stdin, attempts to use the system's encoding before defaulting to utf-8.
October 2022 htmlmin 0.1.12