/* Script compression helper */
The CodeMirror scripts, as distributed, are many, and full of comments. To optimize page loading, it is recommended to concatenate the scripts loaded in the CodeMirror frame, and compress them. This page may be useful if you intend to do this: it provides an interface to two different minifiers, UglifyJS and Google's Closure compiler, allowing you to easily feed them CodeMirror scripts.
You will have to compress codemirror.js
separately, since that will be loaded into the top-level page from
which you use CodeMirror. Inside the frame, the
parserfile
and basefiles
options control
which files are loaded. If you combine the parser(s) you need with
the basefiles, you can set basefiles
to point at your
compressed file, and leave parserfiles
at
[]
.
For example, you have a page that uses CodeMirror to edit some
JavaScript code. You could save a minimized version of
codemirror.js
as codemirror_min.js
, and
include that (with a <script>
tag) in your page.
Next, you compress all the files under "In-frame base code", plus
tokenizejavascript.js
and
parsejavascript.js
into
codemirror_base.js
, and load the editor like
this:
CodeMirror.fromTextArea("mytextarea", { basefiles: ["js/codemirror_base.js"], lineNumbers: true });
Clicking the "Compress with UglifyJS" button will download the compressed file. If you use Closure, that doesn't support direct downloads, so the button will take you to a file containing the compressed code. Copy-paste this into your script file. ("Save as" for that page is broken on some browsers, so be careful).