Skip to content

Commit b3390fe

Browse files
committed
Fixed #13290 - Added a section about minification of admin JavaScript files to the contributing docs. Thanks to Gabriel Hurley for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12969 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 31f7ff1 commit b3390fe

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

django/contrib/admin/media/js/compress.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
def main():
1010
usage = "usage: %prog [file1..fileN]"
1111
description = """With no file paths given this script will automatically
12-
compress all jQuery based files of the admin app."""
12+
compress all jQuery-based files of the admin app. Requires the Google Closure
13+
Compiler library and Java version 6 or later."""
1314
parser = optparse.OptionParser(usage, description=description)
1415
parser.add_option("-c", dest="compiler", default="~/bin/compiler.jar",
15-
help="path to closure compiler jar file")
16+
help="path to Closure Compiler jar file")
1617
parser.add_option("-v", "--verbose",
1718
action="store_true", dest="verbose")
1819
parser.add_option("-q", "--quiet",
@@ -21,7 +22,7 @@ def main():
2122

2223
compiler = os.path.expanduser(options.compiler)
2324
if not os.path.exists(compiler):
24-
sys.exit("Closure compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
25+
sys.exit("Google Closure compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
2526

2627
if not args:
2728
if options.verbose:

docs/internals/contributing.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,44 @@ translated, here's what to do:
433433

434434
.. _Django i18n mailing list: http://groups.google.com/group/django-i18n/
435435

436+
Submitting javascript patches
437+
=============================
438+
439+
.. versionadded:: 1.2
440+
441+
Django's admin system leverages the jQuery framework to increase the
442+
capabilities of the admin interface. In conjunction, there is an emphasis on
443+
admin javascript performance and minimizing overall admin media file size.
444+
Serving compressed or "minified" versions of javascript files is considered
445+
best practice in this regard.
446+
447+
To that end, patches for javascript files should include both the original
448+
code for future development (e.g. "foo.js"), and a compressed version for
449+
production use (e.g. "foo.min.js"). Any links to the file in the codebase
450+
should point to the compressed version.
451+
452+
To simplify the process of providing optimized javascript code, Django
453+
includes a handy script which should be used to create a "minified" version.
454+
This script is located at ``/contrib/admin/media/js/compress.py``.
455+
456+
Behind the scenes, ``compress.py`` is a front-end for Google's
457+
`Closure Compiler`_ which is written in Java. However, the Closure Compiler
458+
library is not bundled with Django directly, so those wishing to contribute
459+
complete javascript patches will need to download and install the library
460+
independently.
461+
462+
The Closure Compiler library requires Java version 6 or higher (Java 1.6 or
463+
higher on Mac OS X). Note that Mac OS X 10.5 and earlier did not ship with Java
464+
1.6 by default, so it may be necessary to upgrade your Java installation before
465+
the tool will be functional. Also note that even after upgrading Java, the
466+
default `/usr/bin/java` command may remain linked to the previous Java
467+
binary, so relinking that command may be necessary as well.
468+
469+
Please don't forget to run ``compress.py`` and include the ``diff`` of the
470+
minified scripts when submitting patches for Django's javascript.
471+
472+
.. _Closure Compiler: http://code.google.com/closure/compiler/
473+
436474
Django conventions
437475
==================
438476

0 commit comments

Comments
 (0)