{"id":23749,"library":"flask-minify","title":"Flask-Minify","description":"Flask extension that automatically minifies HTML, CSS, JS and Less responses using various minifiers. Current version 0.50, released April 2025. Active development, roughly quarterly releases.","status":"active","version":"0.50","language":"python","source_language":"en","source_url":"https://github.com/mrf345/flask_minify","tags":["flask","minify","html","css","javascript","less","web","performance"],"install":[{"cmd":"pip install flask-minify","lang":"bash","label":"Default install"},{"cmd":"pip install flask-minify[htmlmin]","lang":"bash","label":"With htmlmin support (recommended for HTML)"},{"cmd":"pip install flask-minify[tdewolff]","lang":"bash","label":"With tdewolff minifier (faster HTML/CSS/JS)"}],"dependencies":[{"reason":"Core dependency, Flask application must be present","package":"Flask","optional":false},{"reason":"Minify CSS when using default minifiers","package":"cssmin","optional":true},{"reason":"Minify JavaScript when using default minifiers","package":"jsmin","optional":true},{"reason":"Minify HTML when using htmlmin backend (slower but more thorough)","package":"htmlmin","optional":true},{"reason":"Alternative fast minifier backend for HTML, CSS, JS","package":"tdewolff-minify","optional":true},{"reason":"Compile Less files to CSS","package":"lesscpy","optional":true}],"imports":[{"note":"Main class to initialize the extension.","wrong":"","symbol":"Minify","correct":"from flask_minify import Minify"},{"note":"In versions >=0.50, the decorator is imported directly from flask_minify. The old path may still work but is not guaranteed.","wrong":"from flask_minify.decorators import minify_response","symbol":"decorators","correct":"from flask_minify import minify_response"}],"quickstart":{"code":"from flask import Flask\nfrom flask_minify import Minify\n\napp = Flask(__name__)\nMinify(app=app, html=True, css=True, js=True)\n\n@app.route('/')\ndef index():\n    return '<html><body><h1>Hello</h1></body></html>'\n\nif __name__ == '__main__':\n    app.run()","lang":"python","description":"Initialize Minify with the Flask app. By default, only HTML is minified if no arguments are passed. Explicitly enable CSS/JS."},"warnings":[{"fix":"Use Python >=3.8; remove any usage of the 'dash' parameter.","message":"In version 0.49, support for Python 3.7 was dropped and the dash option (--dash) was removed. Upgrade Python to 3.8+.","severity":"breaking","affected_versions":">=0.49"},{"fix":"Use the default backend or install tdewolff-minify (pip install flask-minify[tdewolff]) for better support.","message":"The `htmlmin` backend is unmaintained; the library switched to a fork in 0.43. Using htmlmin may cause compatibility issues in the future.","severity":"deprecated","affected_versions":">=0.43"},{"fix":"Install with extras: pip install flask-minify[htmlmin] or pip install flask-minify[tdewolff] to ensure minifiers are available.","message":"If you install only the base package, minification of CSS/JS may silently fail because cssmin/jsmin are optional dependencies. The extension will still serve the original content without error.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the global Minify(app=app) initialization for class-based views, or apply the decorator manually inside the method's return.","message":"The `minify_response` decorator does not work on class-based views (MethodView). It only works on view functions.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure your route returns files with .less extension, or override the Content-Type header to text/less.","message":"Less compilation is only triggered if the response has a .less extension. If you serve Less files with a wrong Content-Type, it won't compile.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade to latest: pip install --upgrade flask-minify. Also clear __pycache__ if needed.","cause":"Old version (pre-0.39) used a different import pattern; or a stale cached .pyc.","error":"AttributeError: module 'flask_minify' has no attribute 'Minify'"},{"fix":"Use 'from flask_minify import minify_response' for version >=0.50.","cause":"The decorator was moved to the main module in 0.50. Old imports from flask_minify.decorators break.","error":"ImportError: cannot import name 'minify_response' from 'flask_minify'"},{"fix":"Remove the 'dash' argument from Minify() call. It is no longer supported.","cause":"The 'dash' parameter was removed in version 0.49.","error":"TypeError: Minify() got an unexpected keyword argument 'dash'"},{"fix":"Upgrade Python to >=3.8; install wheel: pip install wheel; then retry.","cause":"Missing build dependencies or incompatible Python version (e.g., Python 3.7 before 0.49).","error":"pip install flask-minify fails with error: legacy-install-failure (or similar)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}