A mkdocs plugin to minify the HTML of a page before it is written to disk.
Python
195
56 commits
updated Feb 7, 2024
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.
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.
minify_html:
False.minify_js:
False.True, you must specify the JS to be minified files using js_files (see below).minify_css:
False.True, you must specify the CSS to be minified files using css_files (see below).htmlmin_opts:
None.cache_safe:
False.True, you must specify the files using js_files or css_files (see below).js_files:
None..min.js in the output directory.css_files:
None..min.css in the output directory.Note: When using
minify_jsorminify_css, you don't have to modify theextra_javascriptorextra_cssentries in yourmkdocs.ymlfile. The plugins automatically takes care of that. Bothminify_jsandminify_csssupport the use of globs (e.g.**/*.css).
517 followers · starred May 2024
117 followers · starred May 2021
3,118 followers · starred May 2019
Python
99.4%
A mkdocs plugin to minify the HTML of a page before it is written to disk.
Python
195
56 commits
updated Feb 7, 2024
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.
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.
minify_html:
False.minify_js:
False.True, you must specify the JS to be minified files using js_files (see below).minify_css:
False.True, you must specify the CSS to be minified files using css_files (see below).htmlmin_opts:
None.cache_safe:
False.True, you must specify the files using js_files or css_files (see below).js_files:
None..min.js in the output directory.css_files:
None..min.css in the output directory.Note: When using
minify_jsorminify_css, you don't have to modify theextra_javascriptorextra_cssentries in yourmkdocs.ymlfile. The plugins automatically takes care of that. Bothminify_jsandminify_csssupport the use of globs (e.g.**/*.css).
517 followers · starred May 2024
117 followers · starred May 2021
3,118 followers · starred May 2019
Python
99.4%