skillfed

django-compressor

Compresses linked and inline JavaScript or CSS into single cached files.

django-compressor v4.6.0 2.3M downloads/30d#3,174 on PyPI2,870
Permissive license MIT Active released

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-compressor

uv

uv add django-compressor

poetry

poetry add django-compressor

Installing 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

Development Status :: 5 - Production/StableFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.1Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Internet :: WWW/HTTP

Tags

django css js minificationstatic file compression djangocombine minify css javascriptdjango template asset optimizationcss js concatenation cachingdjango static file pipelineasset compression django
django-middlewareasset-pipelineperformance-optimization

More WWW/HTTP packages