jinja2-htmlmin
Automatic HTML minification for Jinja2 templates.
Why Use This?
- Zero runtime overhead: Minification happens once at load time, not on every render
- Smaller HTML: Reduced bandwidth and faster page loads
- Drop-in compatibility: Works with any Jinja2 loader (Flask, Django, FastAPI, etc.)
- Broad Python support: Compatible with Python 3.9+
- Semantic Versioning: Predictable, reliable updates
- Zero-Clause BSD: Public domain, use freely anywhere
Installation
pip install jinja2-htmlmin
Quick Start
from jinja2 import Environment, FileSystemLoader
from jinja2_htmlmin import minify_loader
# Wrap any Jinja2 loader
# See https://htmlmin.readthedocs.io/en/latest/reference.html for options
env = Environment(
loader=minify_loader(
FileSystemLoader("templates"),
remove_comments=True,
remove_empty_space=True,
remove_all_empty_space=True,
reduce_boolean_attributes=True,
)
)
# Rendered HTML is automatically minified
html = env.get_template('index.html').render(title='My Page')
How It Works
- Template loads normally through your existing loader
- Jinja2 syntax is temporarily protected during minification
- HTML content is minified using htmlmin2
- Jinja2 syntax is restored and template compiles as usual
- Jinja2's built-in caching means this happens only once per template
Metadata
Release files for jinja2-htmlmin 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jinja2_htmlmin-1.1.0.tar.gz | 8.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jinja2_htmlmin-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.1 kB
Release files / jinja2_htmlmin-1.1.0.tar.gz
| Download URL | jinja2_htmlmin-1.1.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4957eab8d1f44bb743d9f85b8effe38915ca65d0b8c73df12e01147f709a065c
|
|
BLAKE2b-256 checksum How to use checksums |
b5d62b74d30b6f191471269b3e612951313b3efc694fb5ef0c5902aef090a811
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 5, 2026.
Transparency logRelease files / jinja2_htmlmin-1.1.0-py3-none-any.whl
| Download URL | jinja2_htmlmin-1.1.0-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39b02b4d1b6f7b28aec7ac7ba97c00af5abbb2d38ab9bb973ff0323f4c5b692c
|
|
BLAKE2b-256 checksum How to use checksums |
75eb4b7d8b0d4cebe0bd404b71d812bb33f95c3691a0121113e3b7e4531d04e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 5, 2026.
Transparency log