RETIRED, further work has moved to Debian project infrastructure
Go to file
Mathieu Pillard 0c8f33aa64 Merge pull request #681 from scop/py34
Add 3.4 trove classifier
2015-10-18 19:46:29 +03:00
compressor Replace SortedDict with OrderedDict 2015-10-09 22:02:24 +02:00
docs Merge pull request #572 from FlightDataServices/multiple-offline-contexts 2015-09-25 22:49:13 +02:00
requirements Merge pull request #670 from gasman/fix/overextends 2015-10-02 14:13:23 +02:00
.gitignore Specifically test saving with the gzip middleware. 2013-05-27 12:52:17 +02:00
.travis.yml Remove Django 1.5 and 1.6 from tox and travis 2015-09-16 16:06:14 +02:00
AUTHORS Add support for multiple offline contexts. 2015-09-25 18:53:05 +01:00
LICENSE Happy New Year! 2014-01-29 10:14:54 +01:00
Makefile Small refactoring of the Makefile 2015-07-01 01:36:46 +02:00
MANIFEST.in Added a couple of files to the source package manifest. Fixes #410. 2013-05-30 20:10:16 +02:00
README.rst Switch from coveralls to codecov badge 2015-09-15 22:55:15 -07:00
setup.cfg Mark this as a universal wheel 2014-05-10 09:31:22 -07:00
setup.py Add 3.4 trove classifier 2015-10-18 14:52:06 +03:00
tox.ini Merge pull request #670 from gasman/fix/overextends 2015-10-02 14:13:23 +02:00

Django Compressor

image

image

image

Build Status

image

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.