Skip to main content
Build Status

Django Compressor combines and compresses linked and inline Javascript or CSS in a Django templates into cacheable static files by using the compress template tag.

HTML in between {% compress js/css %} and {% endcompress %} is parsed and searched for CSS or JS. These styles and scripts are subsequently processed with optional, configurable compilers and filters.

The default filter for CSS rewrites paths to static files to be absolute and adds a cache busting timestamp. For Javascript the default filter compresses it using jsmin.

As the final result the template tag outputs a <script> or <link> tag pointing to the optimized file. These files are stored inside a folder and given an unique name based on their content. Alternatively it can also return the resulting content to the original template directly.

Since the file name is dependend on the content these files can be given a far future expiration date without worrying about stale browser caches.

The concatenation and compressing process can also be jump started outside of the request/response cycle by using the Django management command manage.py compress.

Configurability & Extendibility

Django Compressor is highly configurable and extendible. The HTML parsing is done using lxml or if it’s not available Python’s built-in HTMLParser by default. As an alternative Django Compressor provides a BeautifulSoup and a html5lib based parser, as well as an abstract base class that makes it easy to write a custom parser.

Django Compressor also comes with built-in support for CSS Tidy, YUI CSS and JS compressor, the Google’s Closure Compiler, a Python port of Douglas Crockford’s JSmin, a Python port of the YUI CSS Compressor cssmin and a filter to convert (some) images into data URIs.

If your setup requires a different compressor or other post-processing tool it will be fairly easy to implement a custom filter. Simply extend from one of the available base classes.

More documentation about the usage and settings of Django Compressor can be found on django-compressor.readthedocs.org.

The source code for Django Compressor can be found and contributed to on github.com/jezdez/django_compressor. There you can also file tickets.

The in-development version of Django Compressor can be installed with pip install http://github.com/django-compressor/django-compressor/tarball/develop.

Release files for django-compressor 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-compressor 1.3
File Size Uploaded
django_compressor-1.3.tar.gz 91.2 kB Details

Release files / django_compressor-1.3.tar.gz

Download URL django_compressor-1.3.tar.gz
Size 91.2 kB
Tags Source
SHA-256 checksum
How to use checksums
66ff1a845a6c1b16c4cf552ee3d746033979e46cd9bd5d999d4b5dae93327a52
BLAKE2b-256 checksum
How to use checksums
ee09144c1f5f2d315c5a4882bb9d8f6afc293a0de46193ccebca7d06d084e62a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

4.6.0

2 release files

4.5.1

2 release files

4.5

2 release files

4.4

2 release files

4.3.1

2 release files

4.3

2 release files

4.2

2 release files

4.1

2 release files

4.0

2 release files

3.1

2 release files

3.0

2 release files

2.4.1

2 release files

2.4

2 release files

2.3

2 release files

2.2

2 release files

2.1.1

2 release files

2.1

2 release files

2.0

2 release files

1.6

2 release files

1.5

2 release files

1.4

2 release files

This release

1.3 This release

1 release file

1.2

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1

1 release file

1.0.1

1 release file

1.0

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9

1 release file

0.8

1 release file

0.7.1

1 release file

0.7

1 release file

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6

1 release file

0.5.3

1 release file

0.5.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page