DEV Community

Arnaldo Gabriel
Arnaldo Gabriel

Posted on

A Quick Way of Minifying an HTML File

Note to self

A quick way of minifying an HTML file including the <style> and <script> tags within it.

  1. Start by installing the HTML minifier with:
    npm install html-minifier -g

  2. Execute the minifier command:
    html-minifier --minify-css true --minify-js true input.htm -o output.htm

Additional options:
--collapse-whitespace
--remove-comments
--remove-optional-tags
--remove-redundant-attributes
--remove-script-type-attributes
--remove-tag-whitespace
--use-short-doctype

Top comments (1)

Collapse
 
dpaine20 profile image
David Paine20 •

For the people, who want to do that process, through the online tool, they can use those links as well
url-decode.com/tool/minifyhtml
minifycode.com/
willpeavy.com/tools/minifier/