Install & Compatibility
Where this runs
tested against v0.50 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.915 runs
installs and imports cleanly · install 0.0s · import 0.518s · 26MB
glibcpy 3.10–3.915 runs
installs and imports cleanly · install 3.5s · import 0.484s · 27MB
24MB installed
● package 24MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Minify
✓ from flask_minify import Minify
Main class to initialize the extension.
decorators
✓ from flask_minify import minify_response
✗ from flask_minify.decorators import minify_response
In versions >=0.50, the decorator is imported directly from flask_minify. The old path may still work but is not guaranteed.
Initialize Minify with the Flask app. By default, only HTML is minified if no arguments are passed. Explicitly enable CSS/JS.
from flask import Flask
from flask_minify import Minify
app = Flask(__name__)
Minify(app=app, html=True, css=True, js=True)
@app.route('/')
def index():
return '<html><body><h1>Hello</h1></body></html>'
if __name__ == '__main__':
app.run()
Errors
Common errors & fixes
AttributeError: module 'flask_minify' has no attribute 'Minify'
Old version (pre-0.39) used a different import pattern; or a stale cached .pyc.
fixUpgrade to latest: pip install --upgrade flask-minify. Also clear __pycache__ if needed.
ImportError: cannot import name 'minify_response' from 'flask_minify'
The decorator was moved to the main module in 0.50. Old imports from flask_minify.decorators break.
fixUse 'from flask_minify import minify_response' for version >=0.50.
TypeError: Minify() got an unexpected keyword argument 'dash'
The 'dash' parameter was removed in version 0.49.
fixRemove the 'dash' argument from Minify() call. It is no longer supported.
pip install flask-minify fails with error: legacy-install-failure (or similar)
Missing build dependencies or incompatible Python version (e.g., Python 3.7 before 0.49).
fixUpgrade Python to >=3.8; install wheel: pip install wheel; then retry.
Upgrade
Version history
0.50latest on PyPI · released Mar 29, 2025
Audit
Dependencies
FlaskrequiredCore dependency, Flask application must be present
cssminoptionalMinify CSS when using default minifiers
jsminoptionalMinify JavaScript when using default minifiers
htmlminoptionalMinify HTML when using htmlmin backend (slower but more thorough)
tdewolff-minifyoptionalAlternative fast minifier backend for HTML, CSS, JS
lesscpyoptionalCompile Less files to CSS