Coder Social home page Coder Social logo

dtran320 / django_compressor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from django-compressor/django-compressor

1.0 2.0 0.0 784 KB

Compresses linked and inline javascript or CSS into a single cached file.

Home Page: http://django_compressor.rtfd.org/

License: Other

django_compressor's Introduction

Django Compressor

Django Compressor combines and compresses linked and inline Javascript or CSS in a Django templates 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 an unique name based on their content. Alternatively it can also return the resulting content to the original template directly.

Since the file name is dependend 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, 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/jezdez/django_compressor. There you can also file tickets.

The in-development version of Django Compressor can be installed with pip install django_compressor==dev or easy_install django_compressor==dev.

django_compressor's People

Contributors

acdha avatar baratrion avatar beniwohli avatar benspaulding avatar brutasse avatar carljm avatar copitux avatar diox avatar dziegler avatar emirotin avatar fennb avatar gvangool avatar jaap3 avatar jasondavies avatar jezdez avatar jphalip avatar jsma avatar justinabrahms avatar mintchaos avatar muhuk avatar mvdwaeter avatar ncharlot avatar originell avatar philippbosch avatar selwin avatar shabda avatar streeter avatar ulope avatar wunki avatar yumike avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.