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
- INPUT
- File path to html file to minify. Defaults to stdin.
- OUTPUT
- File path to output to. Defaults to stdout.
- -h, --help
- show this help message and exit
- -c,
--remove-comments
- 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
-->.
- -s,
--remove-empty-space
- 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.
- --remove-all-empty-space
- 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.
- --keep-optional-attribute-quotes
- When set, this keeps all attribute quotes, even if they are optional.
- -H, --in-head
- 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.
- -k,
--keep-pre-attr
- 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.
- -a PRE_ATTR,
--pre-attr PRE_ATTR
- 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'.
- -p [TAG ...],
--pre-tags [TAG ...]
- 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.
- -e ENCODING,
--encoding ENCODING
- 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.