Compress/combine our CSS and JavaScript files.

Review Request #2656 — Created Oct. 12, 2011 and submitted


Review Board


Compress/combine our CSS and JavaScript files.

For too long, we've had many verbose CSS and JavaScript files on production
systems, which affected load time. We didn't have a good system in place
for minifying/combining files.

Now we use django-compress, which is a pretty awesome little module that
allows you to easily define packages of CSS/JavaScript files. When DEBUG
is on, the original files will be used in the templates, but when off,
the minified versions will be used.

django-compress will generally try to minify on demand if it doesn't
find the files, but we make sure to build these files as part of the
packaging operations. This ensures that our users will have the proper
minified versions.

The next step will be to add a new CSS filter class that processes
lessCSS files. I'll be adding this to Djblets as a utility filter for
django-compress, and then begin porting to less.
Tested each affected page in both compressed mode and debug mode. Everything
looked and acted correctly from what I can tell. This could stand some dog-fooding,
though, and some scripts (diffviewer.js, for example) always assumed it was in its
proper page before.
Description From Last Updated

It would be cool if this could process directly into build/.

  2. reviewboard/ (Diff revision 1)
    It would be cool if this could process directly into build/.
    1. You mean the root build/ directory, or like rb/js/build/ ?
    2. The root build/ directory.
    3. Not sure why we'd want it there? We need it to generate in the media path if we're going to be able to use it. If you have DEBUG set to False, or COMPRESS set to True (for testing), and there's no .min.js file. it'll build it on-the-fly, but it'll need to be in a media directory. 
    4. Okay, cool.
  1. Also, did you test making a distribution and checking that the minified files ended up in the right place?
    1. Yep. Works perfectly.
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (ccc8ee1)