Chris Craik | beca7ae | 2015-04-07 13:29:55 -0700 | [diff] [blame^] | 1 | <?xml version="1.0" encoding="ascii"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 3 | "DTD/xhtml1-transitional.dtd"> |
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 5 | <head> |
| 6 | <title>rjsmin</title> |
| 7 | <link rel="stylesheet" href="epydoc.css" type="text/css" /> |
| 8 | <script type="text/javascript" src="epydoc.js"></script> |
| 9 | </head> |
| 10 | |
| 11 | <body bgcolor="white" text="black" link="blue" vlink="#204080" |
| 12 | alink="#204080"> |
| 13 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 14 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 15 | bgcolor="#a0c0ff" cellspacing="0"> |
| 16 | <tr valign="middle"> |
| 17 | <!-- Home link --> |
| 18 | <th bgcolor="#70b0f0" class="navbar-select" |
| 19 | > Home </th> |
| 20 | |
| 21 | <!-- Tree link --> |
| 22 | <th> <a |
| 23 | href="module-tree.html">Trees</a> </th> |
| 24 | |
| 25 | <!-- Index link --> |
| 26 | <th> <a |
| 27 | href="identifier-index.html">Indices</a> </th> |
| 28 | |
| 29 | <!-- Help link --> |
| 30 | <th> <a |
| 31 | href="help.html">Help</a> </th> |
| 32 | |
| 33 | <!-- Project homepage --> |
| 34 | <th class="navbar" align="right" width="100%"> |
| 35 | <table border="0" cellpadding="0" cellspacing="0"> |
| 36 | <tr><th class="navbar" align="center" |
| 37 | ><a href="http://opensource.perlig.de/rjsmin/" target="_top">Visit rjsmin Online</a></th> |
| 38 | </tr></table></th> |
| 39 | </tr> |
| 40 | </table> |
| 41 | <table width="100%" cellpadding="0" cellspacing="0"> |
| 42 | <tr valign="top"> |
| 43 | <td width="100%"> |
| 44 | <span class="breadcrumbs"> |
| 45 | Module rjsmin |
| 46 | </span> |
| 47 | </td> |
| 48 | <td> |
| 49 | <table cellpadding="0" cellspacing="0"> |
| 50 | <!-- hide/show private --> |
| 51 | </table> |
| 52 | </td> |
| 53 | </tr> |
| 54 | </table> |
| 55 | <!-- ==================== MODULE DESCRIPTION ==================== --> |
| 56 | <h1 class="epydoc">Module rjsmin</h1><p class="nomargin-top"><span class="codelink"><a href="rjsmin-pysrc.html">source code</a></span></p> |
| 57 | <p>rJSmin is a javascript minifier written in python.</p> |
| 58 | <p>The minifier is based on the semantics of <a class="rst-reference external" href="http://www.crockford.com/javascript/jsmin.c" target="_top">jsmin.c by Douglas Crockford</a>.</p> |
| 59 | <p>The module is a re-implementation aiming for speed, so it can be used at |
| 60 | runtime (rather than during a preprocessing step). Usually it produces the |
| 61 | same results as the original <tt class="rst-docutils literal">jsmin.c</tt>. It differs in the following ways:</p> |
| 62 | <ul class="rst-simple"> |
| 63 | <li>there is no error detection: unterminated string, regex and comment |
| 64 | literals are treated as regular javascript code and minified as such.</li> |
| 65 | <li>Control characters inside string and regex literals are left untouched; they |
| 66 | are not converted to spaces (nor to n)</li> |
| 67 | <li>Newline characters are not allowed inside string and regex literals, except |
| 68 | for line continuations in string literals (ECMA-5).</li> |
| 69 | <li>"return /regex/" is recognized correctly.</li> |
| 70 | <li>"+ +" and "- -" sequences are not collapsed to '++' or '--'</li> |
| 71 | <li>Newlines before ! operators are removed more sensibly</li> |
| 72 | <li>Comments starting with an exclamation mark (<tt class="rst-docutils literal">!</tt>) can be kept optionally</li> |
| 73 | <li>rJSmin does not handle streams, but only complete strings. (However, the |
| 74 | module provides a "streamy" interface).</li> |
| 75 | </ul> |
| 76 | <p>Since most parts of the logic are handled by the regex engine it's way faster |
| 77 | than the original python port of <tt class="rst-docutils literal">jsmin.c</tt> by Baruch Even. The speed factor |
| 78 | varies between about 6 and 55 depending on input and python version (it gets |
| 79 | faster the more compressed the input already is). Compared to the |
| 80 | speed-refactored python port by Dave St.Germain the performance gain is less |
| 81 | dramatic but still between 3 and 50 (for huge inputs). See the docs/BENCHMARKS |
| 82 | file for details.</p> |
| 83 | <p>rjsmin.c is a reimplementation of rjsmin.py in C and speeds it up even more.</p> |
| 84 | <p>Both python 2 and python 3 are supported.</p> |
| 85 | |
| 86 | <hr /> |
| 87 | <div class="fields"> <p><strong>Copyright:</strong> |
| 88 | Copyright 2011 - 2014 |
| 89 | André Malo or his licensors, as applicable |
| 90 | </p> |
| 91 | <p><strong>License:</strong> |
| 92 | <p>Licensed under the Apache License, Version 2.0 (the "License"); |
| 93 | you may not use this file except in compliance with the License. |
| 94 | You may obtain a copy of the License at</p> |
| 95 | <blockquote> |
| 96 | <a class="rst-reference external" href="http://www.apache.org/licenses/LICENSE-2.0" target="_top">http://www.apache.org/licenses/LICENSE-2.0</a></blockquote> |
| 97 | <p>Unless required by applicable law or agreed to in writing, software |
| 98 | distributed under the License is distributed on an "AS IS" BASIS, |
| 99 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 100 | See the License for the specific language governing permissions and |
| 101 | limitations under the License.</p> |
| 102 | </p> |
| 103 | <p><strong>Version:</strong> |
| 104 | 1.0.10 |
| 105 | </p> |
| 106 | <p><strong>Author:</strong> |
| 107 | André Malo |
| 108 | </p> |
| 109 | </div><!-- ==================== FUNCTIONS ==================== --> |
| 110 | <a name="section-Functions"></a> |
| 111 | <table class="summary" border="1" cellpadding="3" |
| 112 | cellspacing="0" width="100%" bgcolor="white"> |
| 113 | <tr bgcolor="#70b0f0" class="table-header"> |
| 114 | <td align="left" colspan="2" class="table-header"> |
| 115 | <span class="table-header">Functions</span></td> |
| 116 | </tr> |
| 117 | <tr> |
| 118 | <td width="15%" align="right" valign="top" class="summary"> |
| 119 | <span class="summary-type"><tt class="rst-docutils literal">str</tt></span> |
| 120 | </td><td class="summary"> |
| 121 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 122 | <tr> |
| 123 | <td><span class="summary-sig"><a href="rjsmin-module.html#jsmin" class="summary-sig-name">jsmin</a>(<span class="summary-sig-arg">script</span>, |
| 124 | <span class="summary-sig-arg">keep_bang_comments</span>=<span class="summary-sig-default">False</span>)</span><br /> |
| 125 | Minify javascript based on <a class="rst-reference external" href="http://www.crockford.com/javascript/jsmin.c" target="_top">jsmin.c by Douglas Crockford</a>.</td> |
| 126 | <td align="right" valign="top"> |
| 127 | |
| 128 | |
| 129 | </td> |
| 130 | </tr> |
| 131 | </table> |
| 132 | |
| 133 | </td> |
| 134 | </tr> |
| 135 | </table> |
| 136 | <!-- ==================== FUNCTION DETAILS ==================== --> |
| 137 | <a name="section-FunctionDetails"></a> |
| 138 | <table class="details" border="1" cellpadding="3" |
| 139 | cellspacing="0" width="100%" bgcolor="white"> |
| 140 | <tr bgcolor="#70b0f0" class="table-header"> |
| 141 | <td align="left" colspan="2" class="table-header"> |
| 142 | <span class="table-header">Function Details</span></td> |
| 143 | </tr> |
| 144 | </table> |
| 145 | <a name="jsmin"></a> |
| 146 | <div> |
| 147 | <table class="details" border="1" cellpadding="3" |
| 148 | cellspacing="0" width="100%" bgcolor="white"> |
| 149 | <tr><td> |
| 150 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 151 | <tr valign="top"><td> |
| 152 | <h3 class="epydoc"><span class="sig"><span class="sig-name">jsmin</span>(<span class="sig-arg">script</span>, |
| 153 | <span class="sig-arg">keep_bang_comments</span>=<span class="sig-default">False</span>)</span> |
| 154 | </h3> |
| 155 | </td><td align="right" valign="top" |
| 156 | > |
| 157 | </td> |
| 158 | </tr></table> |
| 159 | |
| 160 | <p>Minify javascript based on <a class="rst-reference external" href="http://www.crockford.com/javascript/jsmin.c" target="_top">jsmin.c by Douglas Crockford</a>.</p> |
| 161 | <p>Instead of parsing the stream char by char, it uses a regular |
| 162 | expression approach which minifies the whole script with one big |
| 163 | substitution regex.</p> |
| 164 | <dl class="fields"> |
| 165 | <dt>Parameters:</dt> |
| 166 | <dd><ul class="nomargin-top"> |
| 167 | <li><strong class="pname"><code>script</code></strong> (<tt class="rst-docutils literal">str</tt>) - Script to minify</li> |
| 168 | <li><strong class="pname"><code>keep_bang_comments</code></strong> (<tt class="rst-docutils literal">bool</tt>) - Keep comments starting with an exclamation mark? (<tt class="rst-docutils literal"><span class="pre">/*!...*/</span></tt>)</li> |
| 169 | </ul></dd> |
| 170 | <dt>Returns: <tt class="rst-docutils literal">str</tt></dt> |
| 171 | <dd>Minified script</dd> |
| 172 | </dl> |
| 173 | <div class="fields"> <p><strong>Note:</strong> |
| 174 | This is a hand crafted C implementation built on the regex |
| 175 | semantics. |
| 176 | </p> |
| 177 | </div></td></tr></table> |
| 178 | </div> |
| 179 | <br /> |
| 180 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 181 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 182 | bgcolor="#a0c0ff" cellspacing="0"> |
| 183 | <tr valign="middle"> |
| 184 | <!-- Home link --> |
| 185 | <th bgcolor="#70b0f0" class="navbar-select" |
| 186 | > Home </th> |
| 187 | |
| 188 | <!-- Tree link --> |
| 189 | <th> <a |
| 190 | href="module-tree.html">Trees</a> </th> |
| 191 | |
| 192 | <!-- Index link --> |
| 193 | <th> <a |
| 194 | href="identifier-index.html">Indices</a> </th> |
| 195 | |
| 196 | <!-- Help link --> |
| 197 | <th> <a |
| 198 | href="help.html">Help</a> </th> |
| 199 | |
| 200 | <!-- Project homepage --> |
| 201 | <th class="navbar" align="right" width="100%"> |
| 202 | <table border="0" cellpadding="0" cellspacing="0"> |
| 203 | <tr><th class="navbar" align="center" |
| 204 | ><a href="http://opensource.perlig.de/rjsmin/" target="_top">Visit rjsmin Online</a></th> |
| 205 | </tr></table></th> |
| 206 | </tr> |
| 207 | </table> |
| 208 | |
| 209 | <script type="text/javascript"> |
| 210 | <!-- |
| 211 | // Private objects are initially displayed (because if |
| 212 | // javascript is turned off then we want them to be |
| 213 | // visible); but by default, we want to hide them. So hide |
| 214 | // them unless we have a cookie that says to show them. |
| 215 | checkCookie(); |
| 216 | // --> |
| 217 | </script> |
| 218 | </body> |
| 219 | </html> |