CARVIEW |
mintchaos / django_compressor
- Source
- Commits
- Network (15)
- Issues (3)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
click here to add a description
click here to add a homepage
Pledgie Donations
Once activated, we'll place the following badge in your repository's detail box:
Compresses linked and inline javascript or CSS into a single cached file. — Read more

name | age | message | |
---|---|---|---|
![]() |
.gitignore | Tue Jan 26 07:27:43 -0800 2010 | Fixed exception when using csstidy filter. [richleland] |
![]() |
AUTHORS | Tue Feb 23 09:28:19 -0800 2010 | Made the CSSTidyFilter function. Signed-off-by... [Aaron Godfrey] |
![]() |
LICENSE | Thu Apr 30 01:31:20 -0700 2009 | Packaging and a README [xian] |
![]() |
MANIFEST.in | Thu Apr 30 01:31:20 -0700 2009 | Packaging and a README [xian] |
![]() |
README.rst | Tue Feb 23 04:42:57 -0800 2010 | Merge remote branch 'muhuk/master' Conflicts: ... [Jannis Leidel] |
![]() |
compressor/ | Wed Feb 24 07:17:18 -0800 2010 | Removed CssAbsoluteFilter again from default se... [Jannis Leidel] |
![]() |
setup.py | Wed Feb 24 07:17:36 -0800 2010 | Bumped version up to 0.5.3. [Jannis Leidel] |
![]() |
tests/ | Wed Feb 24 07:09:19 -0800 2010 | Added another test for latin-1 encoded files to... [Jannis Leidel] |
Django compressor
Compresses linked and inline javascript or CSS into a single cached file.
Syntax:
{% compress <js/css> %} <html of inline or linked JS/CSS> {% endcompress %}
Examples:
{% compress css %} <link rel="stylesheet" href="/media/css/one.css" type="text/css" charset="utf-8"> <style type="text/css">p { border:5px solid green;}</style> <link rel="stylesheet" href="/media/css/two.css" type="text/css" charset="utf-8"> {% endcompress %}
Which would be rendered something like:
<link rel="stylesheet" href="/media/CACHE/css/f7c661b7a124.css" type="text/css" charset="utf-8">
or:
{% compress js %} <script src="/media/js/one.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript" charset="utf-8">obj.value = "value";</script> {% endcompress %}
Which would be rendered something like:
<script type="text/javascript" src="/media/CACHE/js/3f33b9146e12.js" charset="utf-8"></script>
Linked files must be on your COMPRESS_URL (which defaults to MEDIA_URL). If DEBUG is true off-site files will throw exceptions. If DEBUG is false they will be silently stripped.
If COMPRESS is False (defaults to the opposite of DEBUG) the compress tag simply returns exactly what it was given, to ease development.
CSS Notes:
All relative url() bits specified in linked CSS files are automatically converted to absolute URLs while being processed. Any local absolute URLs (those starting with a '/') are left alone.
Stylesheets that are @import'd are not compressed into the main file. They are left alone.
If the media attribute is set on <style> and <link> elements, a separate compressed file is created and linked for each media value you specified. This allows the media attribute to remain on the generated link element, instead of wrapping your CSS with @media blocks (which can break your own @media queries or @font-face declarations). It also allows browsers to avoid downloading CSS for irrelevant media types.
Recommendations:
- Use only relative or full domain absolute URLs in your CSS files.
- Avoid @import! Simply list all your CSS files in the HTML, they'll be combined anyway.
Why another static file combiner for django?
Short version: None of them did exactly what I needed.
Long version:
Settings
Django compressor has a number of settings that control it's behavior. They've been given sensible defaults.
COMPRESS
Default: | the opposite of DEBUG |
---|
Boolean that decides if compression will happen.
COMPRESS_URL
Default: | MEDIA_URL |
---|
Controls the URL that linked media will be read from and compressed media will be written to.
COMPRESS_ROOT
Default: | MEDIA_ROOT |
---|
Controls the absolute file path that linked media will be read from and compressed media will be written to.
COMPRESS_OUTPUT_DIR
Default: | 'CACHE' |
---|
Conttrols the directory inside COMPRESS_ROOT that compressed files will be written to.
COMPRESS_CSS_FILTERS
Default: | [] |
---|
A list of filters that will be applied to CSS.
COMPRESS_JS_FILTERS
Default: | ['compressor.filters.jsmin.JSMinFilter'] |
---|
A list of filters that will be applied to javascript.
COMPRESS_STORAGE
Default: | 'compressor.storage.CompressorFileStorage' |
---|
The dotted path to a Django Storage backend to be used to save the compressed files.
Dependecies
- BeautifulSoup