RETIRED, further work has moved to Debian project infrastructure
Go to file
Carlton Gibson 366d8d06b8 Merge pull request #821 from carltongibson/patch/2.1.1-changes
Add 2.1.1 changes
2017-02-03 16:07:56 +01:00
compressor Release 2.1.1 to fix #819 (packaging issue) 2017-02-02 11:38:34 +01:00
docs Formatting changes 2017-02-03 15:54:21 +01:00
requirements Remove test using django-overextends to simplify codebase 2015-12-24 13:09:41 +01:00
.gitignore Ignore .eggs dir 2016-02-03 19:13:51 +02:00
.travis.yml Test with Django 1.10 2016-08-04 11:03:39 +03:00
AUTHORS Add support for multiple offline contexts. 2015-09-25 18:53:05 +01:00
LICENSE Year bump (never too late!) 2015-11-19 19:00:23 +01:00
MANIFEST.in Added a couple of files to the source package manifest. Fixes #410. 2013-05-30 20:10:16 +02:00
Makefile Remove rcssmin and rjsmin from the repo and make them proper dependencies. ref #664 2015-12-04 22:34:05 +01:00
README.rst Use https in codecov URLs, fixes badge in GitHub view 2016-08-04 18:54:43 +03:00
setup.cfg Mark this as a universal wheel 2014-05-10 09:31:22 -07:00
setup.py Convert readthedocs link for their .org -> .io migration for hosted projects 2016-05-31 19:27:39 +01:00
tox.ini Test with Django 1.10 2016-08-04 11:03:39 +03:00

README.rst

Django Compressor

image

image

Build Status

image

Django Compressor processes, combines and minifies linked and inline Javascript or CSS in a Django template into cacheable static files.

It supports compilers such as coffeescript, LESS and SASS and is extensible by custom processing steps.

Django Compressor is compatible with Django 1.8 and newer.

How it works

In your templates, all HTML code between the tags {% 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. Both Javascript and CSS files are by default concatenated and minified.

As the final step the template tag outputs a <script> or <link> tag pointing to the optimized file. Alternatively it can also inline the resulting content into 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.

For increased performance, the concatenation and compressing process can also be run once manually outside of the request/response cycle by using the Django management command manage.py compress.

Configurability & Extensibility

Django Compressor is highly configurable and extensible. 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 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 csscompressor 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.