django-compressor
Compresses linked and inline JavaScript or CSS into single cached files.
What it is and what it does
Django Compressor is a Django app that processes CSS and JavaScript in your templates, combining multiple files into single cached assets and minifying them for production. It wraps your stylesheets and scripts in template tags, parses them for linked and inline resources, applies optional compilers (like LESS or SASS), and outputs optimized `<link>` or `<script>` tags pointing to versioned files. Because the filename is content-dependent, these files can be cached indefinitely without stale-cache concerns.
The package is highly configurable: you can choose between lxml, BeautifulSoup, html5lib, or a custom HTML parser; swap in different minifiers (YUI Compressor, Closure Compiler, JSMin, csscompressor); or write custom filters for post-processing. For offline workflows, a management command lets you pre-compress assets outside the request cycle. It depends on django, django-appconf, rcssmin, and rjsmin, and supports modern Django versions (4.2 through 6.0) and Python 3.10+.
Use it for:
- Reduce HTTP requests and bandwidth by combining multiple CSS files into one cached asset in production
- Automatically minify inline JavaScript and CSS in Django templates without manual build steps
- Compile LESS or SASS stylesheets and minify them in a single pipeline step during template rendering
- Serve versioned static files with far-future cache headers, ensuring browsers never serve stale assets
- Implement custom asset processing (e.g., image-to-data-URI conversion) via extensible filter classes
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Django Compressor combines, minifies, and caches linked and inline CSS or JavaScript in Django templates using configurable compilers and filters.
Yes. Django Compressor is production-stable, actively maintained, has no known vulnerabilities, and solves a common Django performance need with low install friction. Choose it if you need automatic CSS/JS compression in templates with optional compiler support and offline processing. The MIT license carries no restrictions.
Install
django-compressor on PyPI
pip
pip install django-compressoruv
uv add django-compressorpoetry
poetry add django-compressorInstalling django-compressor
Before you install
Low friction install with four runtime dependencies (django, django-appconf, rcssmin, rjsmin). Active maintenance with recent commits and production-stable status across Django 4.2 through 6.0.
License in practice
MIT license permits unrestricted use, modification, and distribution in commercial and private projects with minimal obligations.
Quickstart
pip install django-compressor
# In Django settings.py:
INSTALLED_APPS = ['compressor', ...]
# In template:
{% load compress %}
{% compress css %}
<link rel="stylesheet" href="{% static 'style.css' %}">
{% endcompress %}
Requires Django 4.2 or later and Python 3.10 or later; rcssmin and rjsmin are runtime dependencies for default minification.
Verify before relying
- Performance impact of compression on build times for large static file sets
- Compatibility with specific Django middleware or caching backends beyond the documented defaults
- Whether custom compilers (LESS, SASS, CoffeeScript) require additional system dependencies
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — django, django-appconf, rcssmin, rjsmin |
| Maintenance | actively maintained — 277 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,275,628/month — #3,174 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_compressor-4.6.0-py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
django-pipelinedjango-pipeline bundles and compresses CSS and…
permissive · top 15,000 on PyPI
webassetsMerges and compresses JavaScript and CSS files…
permissive · top 15,000 on PyPI
django-libsassIntegrates Sass compilation into Django…
permissive · top 5,000 on PyPI
csscompressorCompresses CSS by removing unnecessary…
permissive · top 5,000 on PyPI
Flask-AssetsIntegrates asset management into Flask…
permissive · top 15,000 on PyPI
django-sass-processorCompiles SASS/SCSS files to CSS on the fly…
permissive · top 15,000 on PyPI
lesscpyCompiles LESS stylesheets to CSS using Python,…
permissive · top 15,000 on PyPI
mkdocs-minify-pluginMinifies HTML, JavaScript, and CSS files in…
permissive · top 5,000 on PyPI
django-componentsdjango-components lets you build reusable,…
permissive · top 15,000 on PyPI
django-premailerA Django template tag that converts CSS blocks…
permissive · top 15,000 on PyPI