Home | History | Annotate | Download | only in docs
      1 =====================
      2  Javascript Minifier
      3 =====================
      4 
      5 rJSmin is a javascript minifier written in python.
      6 
      7 The minifier is based on the semantics of `jsmin.c by Douglas Crockford`_\.
      8 
      9 The module is a re-implementation aiming for speed, so it can be used at
     10 runtime (rather than during a preprocessing step). Usually it produces the
     11 same results as the original ``jsmin.c``. It differs in the following ways:
     12 
     13 - there is no error detection: unterminated string, regex and comment
     14   literals are treated as regular javascript code and minified as such.
     15 - Control characters inside string and regex literals are left untouched; they
     16   are not converted to spaces (nor to \n)
     17 - Newline characters are not allowed inside string and regex literals, except
     18   for line continuations in string literals (ECMA-5).
     19 - "return /regex/" is recognized correctly.
     20 - Line terminators after regex literals are handled more sensibly
     21 - "+ +" and "- -" sequences are not collapsed to '++' or '--'
     22 - Newlines before ! operators are removed more sensibly
     23 - Comments starting with an exclamation mark (``!``) can be kept optionally
     24 - rJSmin does not handle streams, but only complete strings. (However, the
     25   module provides a "streamy" interface).
     26 
     27 Since most parts of the logic are handled by the regex engine it's way faster
     28 than the original python port of ``jsmin.c`` by Baruch Even. The speed factor
     29 varies between about 6 and 55 depending on input and python version (it gets
     30 faster the more compressed the input already is).  Compared to the
     31 speed-refactored python port by Dave St.Germain the performance gain is less
     32 dramatic but still between 3 and 50 (for huge inputs)). See the
     33 docs/BENCHMARKS file for details.
     34 
     35 rjsmin.c is a reimplementation of rjsmin.py in C and speeds it up even more.
     36 
     37 Both python 2 (>=2.4) and python 3 are supported.
     38 
     39 .. _jsmin.c by Douglas Crockford: http://www.crockford.com/javascript/jsmin.c
     40 
     41 
     42 Copyright and License
     43 ~~~~~~~~~~~~~~~~~~~~~
     44 
     45 Copyright 2011 - 2015
     46 Andr Malo or his licensors, as applicable.
     47 
     48 The whole package (except for the files in the bench/ directory) is
     49 distributed under the Apache License Version 2.0. You'll find a copy in the
     50 root directory of the distribution or online at:
     51 <http://www.apache.org/licenses/LICENSE-2.0>.
     52 
     53 
     54 Bugs
     55 ~~~~
     56 
     57 No bugs, of course. ;-)
     58 But if you've found one or have an idea how to improve rjsmin, feel free
     59 to send a pull request on `github <https://github.com/ndparker/rjsmin>`_
     60 or send a mail to <rjsmin-bugs (a] perlig.de>.
     61 
     62 
     63 Author Information
     64 ~~~~~~~~~~~~~~~~~~
     65 
     66 Andr "nd" Malo <nd perlig.de>
     67 GPG: 0x8103A37E
     68 
     69 
     70     If God intended people to be naked, they would be born that way.
     71     -- Oscar Wilde
     72 
     73 .. vim:tw=72 syntax=rest
     74