• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1=====================
2 Javascript Minifier
3=====================
4
5rJSmin is a javascript minifier written in python.
6
7The minifier is based on the semantics of `jsmin.c by Douglas Crockford`_\.
8
9The module is a re-implementation aiming for speed, so it can be used at
10runtime (rather than during a preprocessing step). Usually it produces the
11same 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
27Since most parts of the logic are handled by the regex engine it's way faster
28than the original python port of ``jsmin.c`` by Baruch Even. The speed factor
29varies between about 6 and 55 depending on input and python version (it gets
30faster the more compressed the input already is).  Compared to the
31speed-refactored python port by Dave St.Germain the performance gain is less
32dramatic but still between 3 and 50 (for huge inputs)). See the
33docs/BENCHMARKS file for details.
34
35rjsmin.c is a reimplementation of rjsmin.py in C and speeds it up even more.
36
37Both 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
42Copyright and License
43~~~~~~~~~~~~~~~~~~~~~
44
45Copyright 2011 - 2015
46André Malo or his licensors, as applicable.
47
48The whole package (except for the files in the bench/ directory) is
49distributed under the Apache License Version 2.0. You'll find a copy in the
50root directory of the distribution or online at:
51<http://www.apache.org/licenses/LICENSE-2.0>.
52
53
54Bugs
55~~~~
56
57No bugs, of course. ;-)
58But if you've found one or have an idea how to improve rjsmin, feel free
59to send a pull request on `github <https://github.com/ndparker/rjsmin>`_
60or send a mail to <rjsmin-bugs@perlig.de>.
61
62
63Author Information
64~~~~~~~~~~~~~~~~~~
65
66André "nd" Malo <nd perlig.de>
67GPG: 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