An MkDocs plugin to minify HTML, JS or CSS files prior to being written to disk
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
Consider insteadmkdocs-minify-html-pluginPythie’s Index: 80145.2K downloads/moCompare →
pip install mkdocs-minify-pluginmkdocs-minify-plugin
An MkDocs plugin to minify HTML, JS or CSS files prior to being written to disk.
HTML minification is done using htmlmin2.
JS minification is done using jsmin.
CSS minification is done using csscompressor.
Setup
Install the plugin using pip:
pip install mkdocs-minify-plugin
Activate the plugin in mkdocs.yml:
plugins:
- search
- minify:
minify_html: true
minify_js: true
minify_css: true
htmlmin_opts:
remove_comments: true
cache_safe: true
js_files:
- my/javascript/dir/file1.js
- my/javascript/dir/file2.js
css_files:
- my/css/dir/file1.css
- my/css/dir/file2.css
Note: If you have no
pluginsentry in your config file yet, you'll likely also want to add thesearchplugin. MkDocs enables it by default if there is nopluginsentry set, but now you have to enable it explicitly.
Options
minify_html:- Defaults to
False. - Sets whether HTML files should be minified.
- Defaults to
minify_js:- Defaults to
False. - Sets whether JS files should be minified.
If set toTrue, you must specify the JS to be minified files usingjs_files(see below).
- Defaults to
minify_css:- Defaults to
False. - Sets whether CSS files should be minified.
If set toTrue, you must specify the CSS to be minified files usingcss_files(see below).
- Defaults to
htmlmin_opts:- Defaults to
None. - Sets runtime htmlmin API options using the
- Defaults to