ProperDocs and MkDocs plugin that minifies HTML pages with their inline CSS and JS, using the minify-html Rust crate
Actively maintained. Last release 2 weeks ago, commits in 26 of the last 26 weeks. A safe choice.
pip install mkdocs-minify-html-plugin
mkdocs-minify-html-plugin
ProperDocs and MkDocs plugin that minifies the built HTML pages, including inline CSS and JS, with minify-html.
ProperDocs instead of MkDocs
MkDocs is no longer maintained, and its last release, 1.6.1, came out in August 2024. MkDocs 2.0, now in development, has no plugin system, so this plugin will not run on it. ProperDocs continues MkDocs 1.x. It reads mkdocs.yml and runs existing plugins without changes, this one included. This plugin still supports MkDocs 1.x as well.
Usage
Install:
uv add --dev mkdocs-minify-html-plugin
# or
pip install -U mkdocs-minify-html-plugin
Activate in properdocs.yml or mkdocs.yml:
plugins:
- search
- minify_html
Options
The options are the fields of minify-html's Cfg. The defaults aim for the smallest output that stays spec-compliant:
plugins:
- search
- minify_html:
allow_noncompliant_unquoted_attribute_values: false
allow_optimal_entities: false
allow_removing_spaces_between_attributes: false
keep_closing_tags: false
keep_comments: false
keep_html_and_head_opening_tags: false
keep_input_type_text_attr: true
keep_ssi_comments: false
minify_css: true
minify_doctype: false
minify_js: true
preserve_brace_template_syntax: false
preserve_chevron_percent_template_syntax: false
remove_bangs: false
remove_processing_instructions: false