PageRenderTime 64ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/README.rst

https://github.com/liberation/django_compressor
ReStructuredText | 71 lines | 55 code | 16 blank | 0 comment | 0 complexity | dede46b56b8477025f2e04b4a003170d MD5 | raw file
  1. Django Compressor
  2. =================
  3. .. image:: https://secure.travis-ci.org/jezdez/django_compressor.png?branch=develop
  4. :alt: Build Status
  5. :target: http://travis-ci.org/jezdez/django_compressor
  6. Django Compressor combines and compresses linked and inline Javascript
  7. or CSS in a Django templates into cacheable static files by using the
  8. ``compress`` template tag.
  9. HTML in between ``{% compress js/css %}`` and ``{% endcompress %}`` is
  10. parsed and searched for CSS or JS. These styles and scripts are subsequently
  11. processed with optional, configurable compilers and filters.
  12. The default filter for CSS rewrites paths to static files to be absolute
  13. and adds a cache busting timestamp. For Javascript the default filter
  14. compresses it using ``jsmin``.
  15. As the final result the template tag outputs a ``<script>`` or ``<link>``
  16. tag pointing to the optimized file. These files are stored inside a folder
  17. and given an unique name based on their content. Alternatively it can also
  18. return the resulting content to the original template directly.
  19. Since the file name is dependend on the content these files can be given
  20. a far future expiration date without worrying about stale browser caches.
  21. The concatenation and compressing process can also be jump started outside
  22. of the request/response cycle by using the Django management command
  23. ``manage.py compress``.
  24. Configurability & Extendibility
  25. -------------------------------
  26. Django Compressor is highly configurable and extendible. The HTML parsing
  27. is done using lxml_ or if it's not available Python's built-in HTMLParser by
  28. default. As an alternative Django Compressor provides a BeautifulSoup_ and a
  29. html5lib_ based parser, as well as an abstract base class that makes it easy to
  30. write a custom parser.
  31. Django Compressor also comes with built-in support for `CSS Tidy`_,
  32. `YUI CSS and JS`_ compressor, the Google's `Closure Compiler`_, a Python
  33. port of Douglas Crockford's JSmin_, a Python port of the YUI CSS Compressor
  34. cssmin_ and a filter to convert (some) images into `data URIs`_.
  35. If your setup requires a different compressor or other post-processing
  36. tool it will be fairly easy to implement a custom filter. Simply extend
  37. from one of the available base classes.
  38. More documentation about the usage and settings of Django Compressor can be
  39. found on `django_compressor.readthedocs.org`_.
  40. The source code for Django Compressor can be found and contributed to on
  41. `github.com/jezdez/django_compressor`_. There you can also file tickets.
  42. The `in-development version`_ of Django Compressor can be installed with
  43. ``pip install django_compressor==dev`` or ``easy_install django_compressor==dev``.
  44. .. _BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/
  45. .. _lxml: http://lxml.de/
  46. .. _html5lib: http://code.google.com/p/html5lib/
  47. .. _CSS Tidy: http://csstidy.sourceforge.net/
  48. .. _YUI CSS and JS: http://developer.yahoo.com/yui/compressor/
  49. .. _Closure Compiler: http://code.google.com/closure/compiler/
  50. .. _JSMin: http://www.crockford.com/javascript/jsmin.html
  51. .. _cssmin: https://github.com/zacharyvoase/cssmin
  52. .. _data URIs: http://en.wikipedia.org/wiki/Data_URI_scheme
  53. .. _django_compressor.readthedocs.org: http://django_compressor.readthedocs.org/
  54. .. _github.com/jezdez/django_compressor: https://github.com/jezdez/django_compressor
  55. .. _in-development version: http://github.com/jezdez/django_compressor/tarball/develop#egg=django_compressor-dev