{"id":13706771,"url":"https://github.com/mkrd/Flask-Squeeze","last_synced_at":"2025-05-05T23:31:30.535Z","repository":{"id":48368703,"uuid":"224402977","full_name":"mkrd/Flask-Squeeze","owner":"mkrd","description":"Automatically minify JS/CSS and compress all responses with brotli, defalte or gzip, with caching for static assets","archived":false,"fork":false,"pushed_at":"2025-04-17T18:24:13.000Z","size":1055,"stargazers_count":13,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T08:40:39.298Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkrd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-27T10:17:05.000Z","updated_at":"2025-04-16T05:43:35.000Z","dependencies_parsed_at":"2022-09-13T15:21:27.659Z","dependency_job_id":"9a4b23c7-ddea-411c-b85d-a2dc7c438632","html_url":"https://github.com/mkrd/Flask-Squeeze","commit_stats":{"total_commits":137,"total_committers":4,"mean_commits":34.25,"dds":"0.25547445255474455","last_synced_commit":"3e935ba757ae5705c4008438b2c4a5fad0163f87"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkrd%2FFlask-Squeeze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkrd%2FFlask-Squeeze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkrd%2FFlask-Squeeze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkrd%2FFlask-Squeeze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkrd","download_url":"https://codeload.github.com/mkrd/Flask-Squeeze/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252593073,"owners_count":21773404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T22:01:07.728Z","updated_at":"2025-05-05T23:31:30.527Z","avatar_url":"https://github.com/mkrd.png","language":"CSS","funding_links":[],"categories":["CSS"],"sub_categories":[],"readme":"![Logo](https://github.com/mkrd/Flask-Squeeze/blob/master/assets/logo.png?raw=true)\n\n[![Downloads](https://pepy.tech/badge/flask-squeeze)](https://pepy.tech/project/flask-squeeze)\n![Tests](https://github.com/mkrd/Flask-Squeeze/actions/workflows/test.yml/badge.svg)\n![Coverage](https://github.com/mkrd/Flask-Squeeze/blob/master/assets/coverage.svg?raw=1)\n\nFlask-Squeeze is a Flask extension that automatically:\n- **Minifies** repsonses with the mimetypes javascript and css\n- **Compresses** all responses with brotli if the browser supports it, or gzip if the browser supports it!\n- **Protects** against the BREACH exploit\n- **Caches** static files so that they don't have to be re-compressed. The cache will be cleared each time Flask restarts. Files are considered static if the the substring \"/static/\" is in their request path.\n\n## Compatibility\n- Tested with Python 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13\n\n## Installation\n```\npip install Flask-Squeeze\n```\n\n## Usage\nInitialize Flask-Squeeze **BEFORE** all other extensions and after_request handlers! Flask executes after_request handlers in reverse order of declaration, and the compression should be the last step before sending the response.\n```python\nfrom flask_squeeze import Squeeze\nsqueeze = Squeeze()\n\ndef create_app():\n    app = Flask(__name__)\n\n    # Init Flask-Squeeze\n    squeeze.init_app(app)\n\n    # Init all other extensions\n    # AFTER Flask-Squeeze\n\n    return app\n```\n\nThats it! The responses of your Flask app will now get minified and compressed, if the browser supports it.\nTo control how Flask-Squeeze behaves, the following options exist:\n\n### General options\nYou can configure Flask-Squeeze with the following options in your [Flask config](https://flask.palletsprojects.com/en/latest/config/):\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `SQUEEZE_COMPRESS` | `True` | Enables or disables compression |\n| `SQUEEZE_MIN_SIZE` | `500` | Defines the minimum file size in bytes to activate the compression |\n| `SQUEEZE_VERBOSE_LOGGING` | `False` | Enable or disable verbose logging. If enabled, Flask-Squeeze will print what it does into the terminal in a highlighted color |\n\n### Minification options\n| Option | Default | Description |\n| --- | --- | --- |\n| `SQUEEZE_MINIFY_CSS` | `True` | Enable or disable css minification using rcssmin |\n| `SQUEEZE_MINIFY_JS` | `True` | Enable or disable js minification using rjsmin |\n\n### Compression level options\n\u003e Static files are chached, so they only have to be compressed once.\n\u003e Dynamic files like generated HTML files will not be cached, so they will be compressed for each response.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `SQUEEZE_LEVEL_BROTLI_STATIC` | `default=11, min=0 , max=11` | Defines the compression level of brotli for static files |\n| `SQUEEZE_LEVEL_BROTLI_DYNAMIC` | `default=1, min=0, max=11` | Defines the compression level of brotli for dynamic files |\n| `SQUEEZE_LEVEL_DEFLATE_STATIC` | `default=9, min=-1 , max=9` | Defines the compression level of deflate for static files |\n| `SQUEEZE_LEVEL_DEFLATE_DYNAMIC` | `default=1, min=-1, max=9` |  Defines the compression level of deflate for dynamic files |\n| `SQUEEZE_LEVEL_GZIP_STATIC` | `default=9, min=0 , max=9` | Defines the compression level of gzip for static files |\n| `SQUEEZE_LEVEL_GZIP_DYNAMIC` | `default=1, min=0, max=9` |  Defines the compression level of gzip for dynamic files |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkrd%2FFlask-Squeeze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkrd%2FFlask-Squeeze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkrd%2FFlask-Squeeze/lists"}