MkDocs Minify Plugin

0.8.0 · active · verified Sun Apr 12

An MkDocs plugin designed to minify HTML, JavaScript, and CSS files before they are written to disk. It leverages `htmlmin2` for HTML, `jsmin` for JavaScript, and `csscompressor` for CSS minification. The project is actively maintained, with regular updates addressing compatibility and feature enhancements.

Warnings

Install

Quickstart

Add the `minify` plugin to your `mkdocs.yml` file under the `plugins` section. Remember to also explicitly add the `search` plugin if you don't have other plugins defined, as MkDocs disables default plugins when a `plugins` section is present. Configure `minify_html`, `minify_js`, `minify_css`, and specify `js_files`/`css_files` for minification.

plugins:
  - search # Often needed, see warnings
  - minify:
      minify_html: true
      minify_js: true
      minify_css: true
      htmlmin_opts:
        remove_comments: true
      cache_safe: true
      js_files:
        - '**/*.js'
      css_files:
        - '**/*.css'

view raw JSON →