Skip to main content

Django Compressor

https://coveralls.io/repos/django-compressor/django-compressor/badge.png?branch=develop https://pypip.in/v/django_compressor/badge.png https://pypip.in/d/django_compressor/badge.png Build Status

Django Compressor combines and compresses linked and inline Javascript or CSS in a Django template 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 a unique name based on their content. Alternatively it can also return the resulting content to the original template directly.

Since the file name is dependent 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, yUglify 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/django-compressor/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.

Metadata

Release files for django-compressor 1.4

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.4
File Size Uploaded Provenance Actions
django_compressor-1.4.tar.gz 106.8 kB Without provenance Details for django_compressor-1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-compressor 1.4
File Interpreter ABI Platform Actions
django_compressor-1.4-py2.py3-none-any.whl Python 3, Python 2 none any Details for django_compressor-1.4-py2.py3-none-any.whl

Total release size: 221.8 kB

Release files / django_compressor-1.4.tar.gz

Download URL django_compressor-1.4.tar.gz
Size 106.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b26034230efcef7d60e5267890eda656dfc49c567f27125d907eee4fe7f9a6ec
BLAKE2b-256 checksum
How to use checksums
52d15571be2f370a853c221ea9f52e1f82deaca1cd6d5b83651853a0896bddd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_compressor-1.4-py2.py3-none-any.whl

Download URL django_compressor-1.4-py2.py3-none-any.whl
Size 115.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
504e441967ac78604ab35f030018fc9a6fa270e6a6e98471d2311fd77f70674b
BLAKE2b-256 checksum
How to use checksums
6e90262d35aa46729e9cb9146601589bdc23c428f3ae6659a95e5f801be34980
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-compressor 1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.4 This release

2 release files No provenance

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