django_compressor 1.5

Compresses linked and inline JavaScript or CSS into single cached files.
<object data="https://pypip.in/v/django_compressor/badge.svg" type="image/svg+xml">https://pypip.in/v/django_compressor/badge.svg</object> <object data="https://pypip.in/d/django_compressor/badge.svg" type="image/svg+xml">https://pypip.in/d/django_compressor/badge.svg</object> <object data="https://caniusepython3.com/project/django_compressor.svg" type="image/svg+xml">https://caniusepython3.com/project/django_compressor.svg</object>

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.

MIT

Author

Jannis Leidel

Pip

django_compressor==1.5

Classifiers

  • Development Status :: 5 - Production/Stable
  • Framework :: Django
  • Intended Audience :: Developers
  • License :: OSI Approved :: MIT License
  • Operating System :: OS Independent
  • Programming Language :: Python
  • Programming Language :: Python :: 2
  • Programming Language :: Python :: 2.6
  • Programming Language :: Python :: 2.7
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.2
  • Programming Language :: Python :: 3.3
  • Topic :: Internet :: WWW/HTTP
File Type Python Version Uploaded On Downloads
django_compressor-1.5.tar.gz Source April 20, 2015 24,359
django_compressor-1.5-py2.py3-none-any.whl Wheel 2.7 April 20, 2015 284,869
Version Release Date
1.5 April 20, 2015
1.4 May 19, 2014
1.3 March 18, 2013
1.2 Aug. 3, 2012
1.1.2 Jan. 10, 2012
1.1.1 Nov. 2, 2011
1.1 Oct. 7, 2011
1.0.1 Sept. 7, 2011
1.0 Sept. 7, 2011
0.9.2 May 23, 2011
0.9.1 May 19, 2011
0.9 May 18, 2011
0.8 May 11, 2011
0.7.1 April 21, 2011
0.7 April 20, 2011
0.6.4 April 18, 2011
0.6.3 April 18, 2011
0.6.2 April 14, 2011
0.6.1 April 13, 2011
0.6 April 12, 2011
0.5.3 Feb. 24, 2010
0.5.2 Feb. 23, 2010
Date Package Version Action
Aug. 24, 2015, 11 p.m. django_compressor 0.8 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.9 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 1.1.1 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.9.1 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.5.3 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.5.2 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.7.1 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.6.1 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.6.2 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.6.3 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 1.0.1 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.6.4 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.6 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.7 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 0.9.2 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 1.3 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 1.2 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 1.1 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 1.0 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 1.1.2 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 1.5 Release Created
Aug. 24, 2015, 11 p.m. django_compressor 1.4 Release Created
Aug. 24, 2015, 11 p.m. django_compressor Package Created