{"id":23272669,"url":"https://github.com/whs/django-static-compress","last_synced_at":"2025-08-21T04:31:35.519Z","repository":{"id":22794562,"uuid":"97335281","full_name":"whs/django-static-compress","owner":"whs","description":"Precompress your Django static files","archived":false,"fork":false,"pushed_at":"2024-12-01T22:48:54.000Z","size":51,"stargazers_count":9,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-01T23:30:04.766Z","etag":null,"topics":["brotli","django","zopfli"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"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/whs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2017-07-15T18:38:40.000Z","updated_at":"2024-09-18T20:48:42.000Z","dependencies_parsed_at":"2023-10-01T03:22:25.611Z","dependency_job_id":"c8c54b1d-12c5-4628-a4ba-1500edeb2c44","html_url":"https://github.com/whs/django-static-compress","commit_stats":{"total_commits":56,"total_committers":4,"mean_commits":14.0,"dds":0.4464285714285714,"last_synced_commit":"b56940b9246714401bdd0b24c2f9595419dc6671"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whs%2Fdjango-static-compress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whs%2Fdjango-static-compress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whs%2Fdjango-static-compress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whs%2Fdjango-static-compress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whs","download_url":"https://codeload.github.com/whs/django-static-compress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230488034,"owners_count":18233892,"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":["brotli","django","zopfli"],"created_at":"2024-12-19T19:18:26.712Z","updated_at":"2024-12-19T19:18:27.327Z","avatar_url":"https://github.com/whs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django-static-compress\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Travis Status](https://travis-ci.org/whs/django-static-compress.svg)](https://travis-ci.org/whs/django-static-compress)\n[![PyPi](https://img.shields.io/pypi/v/django-static-compress.svg)](https://pypi.python.org/pypi/django-static-compress)\n[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\nPrecompress your static files automatically with [Brotli](https://github.com/google/brotli) and [Zopfli](https://github.com/obp/zopfli)\n\n## Installation\n\nInstall this from pip:\n\n```sh\n$ pip install django-static-compress\n```\n\n(you may want to write this in your requirements.txt)\n\nThen update your settings.py:\n\n```py\nSTATICFILES_STORAGE = 'static_compress.CompressedStaticFilesStorage'\n```\n\nWhen you run `python manage.py collectstatic` it will have an additional post-processing pass to compress your static files.\n\nMake sure that your web server is configured to serve precompressed static files:\n\n- If using nginx:\n  - Setup [ngx_http_gzip_static_module](https://nginx.org/en/docs/http/ngx_http_gzip_static_module.html) to serve gzip (.gz) precompressed files.\n  - Out of tree module [ngx_brotli](https://github.com/google/ngx_brotli) is required to serve Brotli (.br) precompressed files.\n- [Caddy](https://caddyserver.com) will serve .gz and .br without additional configuration.\n\nAlso, as Brotli is not supported by all browsers you should make sure that your reverse proxy/CDN honor the Vary header, and your web server set it to [`Vary: Accept-Encoding`](https://blog.stackpath.com/accept-encoding-vary-important).\n\n## Available storages\n\n- `static_compress.CompressedStaticFilesStorage`: Generate `.br` and `.gz` from your static files\n- `static_compress.CompressedManifestStaticFilesStorage`: Like [`ManifestStaticFilesStorage`](https://docs.djangoproject.com/en/1.11/ref/contrib/staticfiles/#manifeststaticfilesstorage), but also generate compressed files for the hashed files\n\nYou can also add support to your own backend by applying `static_compress.CompressMixin` to your class.\n\nBy default it will only compress files ending with `.js`, `.css` and `.svg`. This is controlled by the settings below.\n\n## Settings\n\n_django-static-compress_ settings and their default values:\n\n```py\nSTATIC_COMPRESS_FILE_EXTS = ['js', 'css', 'svg']\nSTATIC_COMPRESS_METHODS = ['gz', 'br']\nSTATIC_COMPRESS_KEEP_ORIGINAL = True\nSTATIC_COMPRESS_MIN_SIZE_KB = 30\n```\n\nAfter compressing the static files, _django-static-compress_ still leaves the original files in _STATIC_ROOT_ folder. If you want to delete (to save disk space), change `STATIC_COMPRESS_KEEP_ORIGINAL` to `False`.\n\nIf the file is too small, it isn't worth compressing. You can change the minimum size in KiB at which file should be compressed, by changing `STATIC_COMPRESS_MIN_SIZE_KB`.\n\nBy default, _django-static-compress_ use Zopfli to compress to gzip. Zopfli compress better than gzip, but will take more time to compress. If you want to create gzip file with built-in zlib compressor, replace `'gz'` with `'gz+zlib'` in `STATIC_COMPRESS_METHODS`.\n\n## File size reduction\n\nHere's some statistics from [TipMe](https://tipme.in.th)'s jQuery and React bundle. Both bundle have related plugins built in with webpack (eg. Bootstrap for jQuery bundle, and [classnames](https://github.com/JedWatson/classnames) for React bundle), and is already minified.\n\n```\n101K jquery.9aa33728c6b5.js\n 33K jquery.9aa33728c6b5.js.gz (33%)\n 31K jquery.9aa33728c6b5.js.br (31%)\n174K react.5c4899aeda53.js\n 51K react.5c4899aeda53.js.gz (29%)\n 44K react.5c4899aeda53.js.br (25%)\n```\n\n(.gz is Zopfli compressed, and .br is Brotli compressed)\n\n## Developing\n\nThis project is [unmaintained](http://unmaintained.tech/). You may use it, but issues and pull requests might be ignored.\n\n1.  Run `python setup.py develop`\n2.  Run `pip install -r requirements-dev.txt \u0026\u0026 pre-commit install`\n3.  Start hacking\n4.  Run test: `python setup.py test`\n5.  Run integration test: `cd integration_test; python manage.py test`\n6.  Commit. Pre-commit will warn if you have any changes.\n\n## License\n\nLicensed under the [MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhs%2Fdjango-static-compress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhs%2Fdjango-static-compress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhs%2Fdjango-static-compress/lists"}