Here is a small extension to the manage command to make deployment of compacted javascript easier (hopefully).
I think this is better explained with a usage example. I have the templates referring both the standard javascript files for easier debugging and compacted ones for deployment (the debug variable is the standard one and allows the split between development/deployment).
{% if debug %}
<script src="{{ MEDIA_URL }}js/jquery-1.2.2b.js"
type="text/javascript"></script>
<script src="{{ MEDIA_URL }}js/jquery.cookie.js"
type="text/javascript"></script>
<script src="{{ MEDIA_URL }}js/jquery.dimensions.js"
type="text/javascript"></script>
<script src="{{ MEDIA_URL }}js/jquery.hoverIntent.js"
type="text/javascript"></script>
<script src="{{ MEDIA_URL }}js/jquery.cluetip.js"
type="text/javascript"></script>
{% else %}
<script src="{{ MEDIA_URL }}js/jqbase-min.js"
type="text/javascript"></script>
{% endif %}
In the settings file I maintain some variables for the JSC command.
JSC_PATH = '/path_to_media/static/js'
JSC_FILES = (
('jqbase-min.js',('jquery-1.2.2b.js', 'jquery.cookie.js',
'jquery.dimensions.js', 'jquery.hoverIntent.js',
'jquery.cluetip.js')),
('jqui-min.js',('ui.mouse.js','ui.draggable.js',
'ui.draggable.ext.js', 'ui.droppable.js',
'ui.droppable.ext.js'))
)
# either jsmin or jspacker, defaults to jsmin
JSC_METHOD = 'jsmin'
The first one is the path to the javascript files, the second is a list of compacted filenames and list of files to be included in the compacted one. The third setting is the method to compact the javascript, with options being the jsmin or the jspacker.
Then in the command line I run
./management.py jsc
to build the compacted files before deployment. Some command line parameters are also available, for example:
./management.py jsc -m jspacker -f jqbase-min.js
The jsc command script (jsmin and jspacker included) must be installed according to these instructions.
I would love to ear about other approaches.









