• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

compressor/H30-Dec-2019-6,0424,691

django_compressor.egg-info/H03-May-2022-11088

docs/H03-May-2022-525280

requirements/H03-May-2022-

AUTHORSH A D30-May-20191.4 KiB9994

LICENSEH A D09-Aug-20166.1 KiB129102

MANIFEST.inH A D27-May-2014323 1110

MakefileH A D30-Dec-2019444 1812

PKG-INFOH A D30-Dec-20195.5 KiB11088

README.rstH A D30-May-20193.9 KiB8564

setup.cfgH A D30-Dec-201961 85

setup.pyH A D30-Dec-20195.5 KiB151123

tox.iniH A D30-Dec-2019617 2928

README.rst

1Django Compressor
2=================
3
4.. image:: https://codecov.io/github/django-compressor/django-compressor/coverage.svg?branch=develop
5    :target: https://codecov.io/github/django-compressor/django-compressor?branch=develop
6
7.. image:: https://img.shields.io/pypi/v/django_compressor.svg
8        :target: https://pypi.python.org/pypi/django_compressor
9
10.. image:: https://secure.travis-ci.org/django-compressor/django-compressor.svg?branch=develop
11    :alt: Build Status
12    :target: http://travis-ci.org/django-compressor/django-compressor
13
14.. image:: https://caniusepython3.com/project/django_compressor.svg
15    :target: https://caniusepython3.com/project/django_compressor
16
17Django Compressor processes, combines and minifies linked and inline
18Javascript or CSS in a Django template into cacheable static files.
19
20It supports compilers such as coffeescript, LESS and SASS and is
21extensible by custom processing steps.
22
23Django Compressor is compatible with Django 1.11 and newer.
24
25How it works
26------------
27In your templates, all HTML code between the tags ``{% compress js/css %}`` and
28``{% endcompress %}`` is parsed and searched for CSS or JS. These styles and
29scripts are subsequently processed with optional, configurable compilers and
30filters.
31
32The default filter for CSS rewrites paths to static files to be absolute.
33Both Javascript and CSS files are by default concatenated and minified.
34
35As the final step the template tag outputs a ``<script>`` or ``<link>``
36tag pointing to the optimized file. Alternatively it can also
37inline the resulting content into the original template directly.
38
39Since the file name is dependent on the content, these files can be given
40a far future expiration date without worrying about stale browser caches.
41
42For increased performance, the concatenation and compressing process
43can also be run once manually outside of the request/response cycle by using
44the Django management command ``manage.py compress``.
45
46Configurability & Extensibility
47-------------------------------
48
49Django Compressor is highly configurable and extensible. The HTML parsing
50is done using lxml_ or if it's not available Python's built-in HTMLParser by
51default. As an alternative Django Compressor provides a BeautifulSoup_ and a
52html5lib_ based parser, as well as an abstract base class that makes it easy to
53write a custom parser.
54
55Django Compressor also comes with built-in support for
56`YUI CSS and JS`_ compressor, `yUglify CSS and JS`_ compressor, the Google's
57`Closure Compiler`_, a Python port of Douglas Crockford's JSmin_, a Python port
58of the YUI CSS Compressor csscompressor_ and a filter to convert (some) images into
59`data URIs`_.
60
61If your setup requires a different compressor or other post-processing
62tool it will be fairly easy to implement a custom filter. Simply extend
63from one of the available base classes.
64
65More documentation about the usage and settings of Django Compressor can be
66found on `django-compressor.readthedocs.org`_.
67
68The source code for Django Compressor can be found and contributed to on
69`github.com/django-compressor/django-compressor`_. There you can also file tickets.
70
71The in-development version of Django Compressor can be installed with
72``pip install git+https://github.com/django-compressor/django-compressor.git``
73
74.. _BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/
75.. _lxml: http://lxml.de/
76.. _html5lib: https://github.com/html5lib/html5lib-python
77.. _YUI CSS and JS: http://developer.yahoo.com/yui/compressor/
78.. _yUglify CSS and JS: https://github.com/yui/yuglify
79.. _Closure Compiler: http://code.google.com/closure/compiler/
80.. _JSMin: http://www.crockford.com/javascript/jsmin.html
81.. _csscompressor: https://github.com/sprymix/csscompressor
82.. _data URIs: http://en.wikipedia.org/wiki/Data_URI_scheme
83.. _django-compressor.readthedocs.org: https://django-compressor.readthedocs.io/en/latest/
84.. _github.com/django-compressor/django-compressor: https://github.com/django-compressor/django-compressor
85