An MkDocs plugin to minify HTML, JS or CSS files prior to being written to disk
Project description
mkdocs-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 config parameters of htmlmin
- Defaults to
cache_safe:- Defaults to
False. - Sets whether a hash should be added to the JS and CSS file names. This ensures that the browser always loads the latest version of the files instead of loading them from the cache.
If set toTrue, you must specify the files usingjs_filesorcss_files(see below).
- Defaults to
js_files:- Defaults to
None. - List of JS files to be minified.
The plugin will generate minified versions of these files and save them as.min.jsin the output directory.
- Defaults to
css_files:- Defaults to
None. - List of CSS files to be minified.
The plugin will generate minified versions of these files and save them as.min.cssin the output directory.
- Defaults to
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).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs-minify-plugin-0.8.0.tar.gz.
File metadata
- Download URL: mkdocs-minify-plugin-0.8.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc11b78b8120d79e817308e2b11539d790d21445eb63df831e393f76e52e753d
|
|
| MD5 |
577e56f2dba062629e93c11dfd57b0af
|
|
| BLAKE2b-256 |
5267fe4b77e7a8ae7628392e28b14122588beaf6078b53eb91c7ed000fd158ac
|
File details
Details for the file mkdocs_minify_plugin-0.8.0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_minify_plugin-0.8.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fba1a3f7bd9a2142c9954a6559a57e946587b21f133165ece30ea145c66aee6
|
|
| MD5 |
8567786934748cba0b9669a9ba2a00ac
|
|
| BLAKE2b-256 |
1bcd2e8d0d92421916e2ea4ff97f10a544a9bd5588eb747556701c983581df13
|