Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated doc

added --no-mangle-functions
  • Loading branch information...
commit 58d36000086b114836d0dc2ea7cebff41f0cc609 1 parent 03f2a85
@mishoo mishoo authored
Showing with 373 additions and 415 deletions.
  1. +368 −413 README.html
  2. +5 −2 README.org
View
781 README.html
@@ -4,10 +4,10 @@
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en" xml:lang="en">
<head>
-<title>UglifyJS -- a JavaScript parser/compressor/beautifier</title>
+<title>UglifyJS &ndash; a JavaScript parser/compressor/beautifier</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta name="generator" content="Org-mode"/>
-<meta name="generated" content="2011-08-29 19:17:55 EEST"/>
+<meta name="generated" content="2011-12-09 14:59:08 EET"/>
<meta name="author" content="Mihai Bazon"/>
<meta name="description" content="a JavaScript parser/compressor/beautifier in JavaScript"/>
<meta name="keywords" content="javascript, js, parser, compiler, compressor, mangle, minify, minifier"/>
@@ -21,6 +21,9 @@
.target { }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
+ .right {margin-left:auto; margin-right:0px; text-align:right;}
+ .left {margin-left:0px; margin-right:auto; text-align:left;}
+ .center {margin-left:auto; margin-right:auto; text-align:center;}
p.verse { margin-left: 3% }
pre {
border: 1pt solid #AEBDCC;
@@ -31,10 +34,22 @@
overflow:auto;
}
table { border-collapse: collapse; }
- td, th { vertical-align: top; }
+ td, th { vertical-align: top; }
+ th.right { text-align:center; }
+ th.left { text-align:center; }
+ th.center { text-align:center; }
+ td.right { text-align:right; }
+ td.left { text-align:left; }
+ td.center { text-align:center; }
dt { font-weight: bold; }
div.figure { padding: 0.5em; }
div.figure p { text-align: center; }
+ div.inlinetask {
+ padding:10px;
+ border:2px solid gray;
+ margin:10px;
+ background: #ffffcc;
+ }
textarea { overflow-x: auto; }
.linenr { font-size:smaller }
.code-highlighted {background-color:#ffff00;}
@@ -71,8 +86,12 @@
</head>
<body>
-<div id="content">
+<div id="preamble">
+
+</div>
+
+<div id="content">
<h1 class="title">UglifyJS &ndash; a JavaScript parser/compressor/beautifier</h1>
@@ -82,25 +101,25 @@ <h1 class="title">UglifyJS &ndash; a JavaScript parser/compressor/beautifier</h1
<ul>
<li><a href="#sec-1">1 UglifyJS &mdash; a JavaScript parser/compressor/beautifier </a>
<ul>
-<li><a href="#sec-1_1">1.1 Unsafe transformations </a>
+<li><a href="#sec-1-1">1.1 Unsafe transformations </a>
<ul>
-<li><a href="#sec-1_1_1">1.1.1 Calls involving the global Array constructor </a></li>
-<li><a href="#sec-1_1_2">1.1.2 <code>obj.toString()</code> ==&gt; <code>obj+“”</code> </a></li>
+<li><a href="#sec-1-1-1">1.1.1 Calls involving the global Array constructor </a></li>
+<li><a href="#sec-1-1-2">1.1.2 <code>obj.toString()</code> ==&gt; <code>obj+“”</code> </a></li>
</ul>
</li>
-<li><a href="#sec-1_2">1.2 Install (NPM) </a></li>
-<li><a href="#sec-1_3">1.3 Install latest code from GitHub </a></li>
-<li><a href="#sec-1_4">1.4 Usage </a>
+<li><a href="#sec-1-2">1.2 Install (NPM) </a></li>
+<li><a href="#sec-1-3">1.3 Install latest code from GitHub </a></li>
+<li><a href="#sec-1-4">1.4 Usage </a>
<ul>
-<li><a href="#sec-1_4_1">1.4.1 API </a></li>
-<li><a href="#sec-1_4_2">1.4.2 Beautifier shortcoming &ndash; no more comments </a></li>
-<li><a href="#sec-1_4_3">1.4.3 Use as a code pre-processor </a></li>
+<li><a href="#sec-1-4-1">1.4.1 API </a></li>
+<li><a href="#sec-1-4-2">1.4.2 Beautifier shortcoming &ndash; no more comments </a></li>
+<li><a href="#sec-1-4-3">1.4.3 Use as a code pre-processor </a></li>
</ul>
</li>
-<li><a href="#sec-1_5">1.5 Compression &ndash; how good is it? </a></li>
-<li><a href="#sec-1_6">1.6 Bugs? </a></li>
-<li><a href="#sec-1_7">1.7 Links </a></li>
-<li><a href="#sec-1_8">1.8 License </a></li>
+<li><a href="#sec-1-5">1.5 Compression &ndash; how good is it? </a></li>
+<li><a href="#sec-1-6">1.6 Bugs? </a></li>
+<li><a href="#sec-1-7">1.7 Links </a></li>
+<li><a href="#sec-1-8">1.8 License </a></li>
</ul>
</li>
</ul>
@@ -134,94 +153,79 @@ <h2 id="sec-1"><span class="section-number-2">1</span> UglifyJS &mdash; a JavaSc
manipulates the AST generated by the parser to provide the following:
</p>
<ul>
-<li>
-ability to re-generate JavaScript code from the AST. Optionally
-indented&mdash;you can use this if you want to “beautify” a program that has
-been compressed, so that you can inspect the source. But you can also run
-our code generator to print out an AST without any whitespace, so you
-achieve compression as well.
+<li>ability to re-generate JavaScript code from the AST. Optionally
+ indented&mdash;you can use this if you want to “beautify” a program that has
+ been compressed, so that you can inspect the source. But you can also run
+ our code generator to print out an AST without any whitespace, so you
+ achieve compression as well.
</li>
-<li>
-shorten variable names (usually to single characters). Our mangler will
-analyze the code and generate proper variable names, depending on scope
-and usage, and is smart enough to deal with globals defined elsewhere, or
-with <code>eval()</code> calls or <code>with{}</code> statements. In short, if <code>eval()</code> or
-<code>with{}</code> are used in some scope, then all variables in that scope and any
-variables in the parent scopes will remain unmangled, and any references
-to such variables remain unmangled as well.
+<li>shorten variable names (usually to single characters). Our mangler will
+ analyze the code and generate proper variable names, depending on scope
+ and usage, and is smart enough to deal with globals defined elsewhere, or
+ with <code>eval()</code> calls or <code>with{}</code> statements. In short, if <code>eval()</code> or
+ <code>with{}</code> are used in some scope, then all variables in that scope and any
+ variables in the parent scopes will remain unmangled, and any references
+ to such variables remain unmangled as well.
</li>
-<li>
-various small optimizations that may lead to faster code but certainly
-lead to smaller code. Where possible, we do the following:
+<li>various small optimizations that may lead to faster code but certainly
+ lead to smaller code. Where possible, we do the following:
<ul>
-<li>
-foo["bar"] ==&gt; foo.bar
+<li>foo["bar"] ==&gt; foo.bar
</li>
-<li>
-remove block brackets <code>{}</code>
+<li>remove block brackets <code>{}</code>
</li>
-<li>
-join consecutive var declarations:
-var a = 10; var b = 20; ==&gt; var a=10,b=20;
+<li>join consecutive var declarations:
+ var a = 10; var b = 20; ==&gt; var a=10,b=20;
</li>
-<li>
-resolve simple constant expressions: 1 +2 * 3 ==&gt; 7. We only do the
-replacement if the result occupies less bytes; for example 1/3 would
-translate to 0.333333333333, so in this case we don't replace it.
+<li>resolve simple constant expressions: 1 +2 * 3 ==&gt; 7. We only do the
+ replacement if the result occupies less bytes; for example 1/3 would
+ translate to 0.333333333333, so in this case we don't replace it.
</li>
-<li>
-consecutive statements in blocks are merged into a sequence; in many
-cases, this leaves blocks with a single statement, so then we can remove
-the block brackets.
+<li>consecutive statements in blocks are merged into a sequence; in many
+ cases, this leaves blocks with a single statement, so then we can remove
+ the block brackets.
</li>
-<li>
-various optimizations for IF statements:
+<li>various optimizations for IF statements:
<ul>
-<li>
-if (foo) bar(); else baz(); ==&gt; foo?bar():baz();
+<li>if (foo) bar(); else baz(); ==&gt; foo?bar():baz();
</li>
-<li>
-if (!foo) bar(); else baz(); ==&gt; foo?baz():bar();
+<li>if (!foo) bar(); else baz(); ==&gt; foo?baz():bar();
</li>
-<li>
-if (foo) bar(); ==&gt; foo&amp;&amp;bar();
+<li>if (foo) bar(); ==&gt; foo&amp;&amp;bar();
</li>
-<li>
-if (!foo) bar(); ==&gt; foo||bar();
+<li>if (!foo) bar(); ==&gt; foo||bar();
</li>
-<li>
-if (foo) return bar(); else return baz(); ==&gt; return foo?bar():baz();
+<li>if (foo) return bar(); else return baz(); ==&gt; return foo?bar():baz();
</li>
-<li>
-if (foo) return bar(); else something(); ==&gt; {if(foo)return bar();something()}
+<li>if (foo) return bar(); else something(); ==&gt; {if(foo)return bar();something()}
</li>
</ul>
+
</li>
-<li>
-remove some unreachable code and warn about it (code that follows a
-<code>return</code>, <code>throw</code>, <code>break</code> or <code>continue</code> statement, except
-function/variable declarations).
+<li>remove some unreachable code and warn about it (code that follows a
+ <code>return</code>, <code>throw</code>, <code>break</code> or <code>continue</code> statement, except
+ function/variable declarations).
</li>
-<li>
-act a limited version of a pre-processor (c.f. the pre-processor of
-C/C++) to allow you to safely replace selected global symbols with
-specified values. When combined with the optimisations above this can
-make UglifyJS operate slightly more like a compilation process, in
-that when certain symbols are replaced by constant values, entire code
-blocks may be optimised away as unreachable.
+<li>act a limited version of a pre-processor (c.f. the pre-processor of
+ C/C++) to allow you to safely replace selected global symbols with
+ specified values. When combined with the optimisations above this can
+ make UglifyJS operate slightly more like a compilation process, in
+ that when certain symbols are replaced by constant values, entire code
+ blocks may be optimised away as unreachable.
</li>
</ul>
+
</li>
</ul>
@@ -229,9 +233,9 @@ <h2 id="sec-1"><span class="section-number-2">1</span> UglifyJS &mdash; a JavaSc
</div>
-<div id="outline-container-1_1" class="outline-3">
-<h3 id="sec-1_1"><span class="section-number-3">1.1</span> <span class="target">Unsafe transformations</span> </h3>
-<div class="outline-text-3" id="text-1_1">
+<div id="outline-container-1-1" class="outline-3">
+<h3 id="sec-1-1"><span class="section-number-3">1.1</span> <span class="target">Unsafe transformations</span> </h3>
+<div class="outline-text-3" id="text-1-1">
<p>
@@ -242,9 +246,9 @@ <h3 id="sec-1_1"><span class="section-number-3">1.1</span> <span class="target">
</div>
-<div id="outline-container-1_1_1" class="outline-4">
-<h4 id="sec-1_1_1"><span class="section-number-4">1.1.1</span> Calls involving the global Array constructor </h4>
-<div class="outline-text-4" id="text-1_1_1">
+<div id="outline-container-1-1-1" class="outline-4">
+<h4 id="sec-1-1-1"><span class="section-number-4">1.1.1</span> Calls involving the global Array constructor </h4>
+<div class="outline-text-4" id="text-1-1-1">
<p>
@@ -253,14 +257,13 @@ <h4 id="sec-1_1_1"><span class="section-number-4">1.1.1</span> Calls involving t
-<pre class="src src-js"><span style="color: #a020f0;">new</span> <span style="color: #228b22;">Array</span>(1, 2, 3, 4) =&gt; [1,2,3,4]
+<pre class="src src-js"><span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3, 4) =&gt; [1,2,3,4]
Array(a, b, c) =&gt; [a,b,c]
-<span style="color: #a020f0;">new</span> <span style="color: #228b22;">Array</span>(5) =&gt; Array(5)
-<span style="color: #a020f0;">new</span> <span style="color: #228b22;">Array</span>(a) =&gt; Array(a)
+<span class="org-keyword">new</span> <span class="org-type">Array</span>(5) =&gt; Array(5)
+<span class="org-keyword">new</span> <span class="org-type">Array</span>(a) =&gt; Array(a)
</pre>
-
<p>
These are all safe if the Array name isn't redefined. JavaScript does allow
one to globally redefine Array (and pretty much everything, in fact) but I
@@ -274,49 +277,48 @@ <h4 id="sec-1_1_1"><span class="section-number-4">1.1.1</span> Calls involving t
-<pre class="src src-js"><span style="color: #b22222;">// </span><span style="color: #b22222;">case 1. globally declared variable
-</span> <span style="color: #a020f0;">var</span> <span style="color: #b8860b;">Array</span>;
- <span style="color: #a020f0;">new</span> <span style="color: #228b22;">Array</span>(1, 2, 3);
+<pre class="src src-js"><span class="org-comment-delimiter">// </span><span class="org-comment">case 1. globally declared variable</span>
+ <span class="org-keyword">var</span> <span class="org-variable-name">Array</span>;
+ <span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3);
Array(a, b);
- <span style="color: #b22222;">// </span><span style="color: #b22222;">or (can be declared later)
-</span> <span style="color: #a020f0;">new</span> <span style="color: #228b22;">Array</span>(1, 2, 3);
- <span style="color: #a020f0;">var</span> <span style="color: #b8860b;">Array</span>;
+ <span class="org-comment-delimiter">// </span><span class="org-comment">or (can be declared later)</span>
+ <span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3);
+ <span class="org-keyword">var</span> <span class="org-variable-name">Array</span>;
- <span style="color: #b22222;">// </span><span style="color: #b22222;">or (can be a function)
-</span> <span style="color: #a020f0;">new</span> <span style="color: #228b22;">Array</span>(1, 2, 3);
- <span style="color: #a020f0;">function</span> <span style="color: #0000ff;">Array</span>() { ... }
+ <span class="org-comment-delimiter">// </span><span class="org-comment">or (can be a function)</span>
+ <span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3);
+ <span class="org-keyword">function</span> <span class="org-function-name">Array</span>() { ... }
-<span style="color: #b22222;">// </span><span style="color: #b22222;">case 2. declared in a function
-</span> (<span style="color: #a020f0;">function</span>(){
- a = <span style="color: #a020f0;">new</span> <span style="color: #228b22;">Array</span>(1, 2, 3);
+<span class="org-comment-delimiter">// </span><span class="org-comment">case 2. declared in a function</span>
+ (<span class="org-keyword">function</span>(){
+ a = <span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3);
b = Array(5, 6);
- <span style="color: #a020f0;">var</span> <span style="color: #b8860b;">Array</span>;
+ <span class="org-keyword">var</span> <span class="org-variable-name">Array</span>;
})();
- <span style="color: #b22222;">// </span><span style="color: #b22222;">or
-</span> (<span style="color: #a020f0;">function</span>(<span style="color: #b8860b;">Array</span>){
- <span style="color: #a020f0;">return</span> Array(5, 6, 7);
+ <span class="org-comment-delimiter">// </span><span class="org-comment">or</span>
+ (<span class="org-keyword">function</span>(<span class="org-variable-name">Array</span>){
+ <span class="org-keyword">return</span> Array(5, 6, 7);
})();
- <span style="color: #b22222;">// </span><span style="color: #b22222;">or
-</span> (<span style="color: #a020f0;">function</span>(){
- <span style="color: #a020f0;">return</span> <span style="color: #a020f0;">new</span> <span style="color: #228b22;">Array</span>(1, 2, 3, 4);
- <span style="color: #a020f0;">function</span> <span style="color: #0000ff;">Array</span>() { ... }
+ <span class="org-comment-delimiter">// </span><span class="org-comment">or</span>
+ (<span class="org-keyword">function</span>(){
+ <span class="org-keyword">return</span> <span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3, 4);
+ <span class="org-keyword">function</span> <span class="org-function-name">Array</span>() { ... }
})();
- <span style="color: #b22222;">// </span><span style="color: #b22222;">etc.
-</span></pre>
-
+ <span class="org-comment-delimiter">// </span><span class="org-comment">etc.</span>
+</pre>
</div>
</div>
-<div id="outline-container-1_1_2" class="outline-4">
-<h4 id="sec-1_1_2"><span class="section-number-4">1.1.2</span> <code>obj.toString()</code> ==&gt; <code>obj+“”</code> </h4>
-<div class="outline-text-4" id="text-1_1_2">
+<div id="outline-container-1-1-2" class="outline-4">
+<h4 id="sec-1-1-2"><span class="section-number-4">1.1.2</span> <code>obj.toString()</code> ==&gt; <code>obj+“”</code> </h4>
+<div class="outline-text-4" id="text-1-1-2">
</div>
@@ -324,9 +326,9 @@ <h4 id="sec-1_1_2"><span class="section-number-4">1.1.2</span> <code>obj.toStrin
</div>
-<div id="outline-container-1_2" class="outline-3">
-<h3 id="sec-1_2"><span class="section-number-3">1.2</span> Install (NPM) </h3>
-<div class="outline-text-3" id="text-1_2">
+<div id="outline-container-1-2" class="outline-3">
+<h3 id="sec-1-2"><span class="section-number-3">1.2</span> Install (NPM) </h3>
+<div class="outline-text-3" id="text-1-2">
<p>
@@ -337,40 +339,39 @@ <h3 id="sec-1_2"><span class="section-number-3">1.2</span> Install (NPM) </h3>
</div>
-<div id="outline-container-1_3" class="outline-3">
-<h3 id="sec-1_3"><span class="section-number-3">1.3</span> Install latest code from GitHub </h3>
-<div class="outline-text-3" id="text-1_3">
+<div id="outline-container-1-3" class="outline-3">
+<h3 id="sec-1-3"><span class="section-number-3">1.3</span> Install latest code from GitHub </h3>
+<div class="outline-text-3" id="text-1-3">
-<pre class="src src-sh"><span style="color: #b22222;">## </span><span style="color: #b22222;">clone the repository
-</span>mkdir -p /where/you/wanna/put/it
-<span style="color: #da70d6;">cd</span> /where/you/wanna/put/it
+<pre class="src src-sh"><span class="org-comment-delimiter">## </span><span class="org-comment">clone the repository</span>
+mkdir -p /where/you/wanna/put/it
+<span class="org-builtin">cd</span> /where/you/wanna/put/it
git clone git://github.com/mishoo/UglifyJS.git
-<span style="color: #b22222;">## </span><span style="color: #b22222;">make the module available to Node
-</span>mkdir -p ~/.node_libraries/
-<span style="color: #da70d6;">cd</span> ~/.node_libraries/
+<span class="org-comment-delimiter">## </span><span class="org-comment">make the module available to Node</span>
+mkdir -p ~/.node_libraries/
+<span class="org-builtin">cd</span> ~/.node_libraries/
ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js
-<span style="color: #b22222;">## </span><span style="color: #b22222;">and if you want the CLI script too:
-</span>mkdir -p ~/bin
-<span style="color: #da70d6;">cd</span> ~/bin
+<span class="org-comment-delimiter">## </span><span class="org-comment">and if you want the CLI script too:</span>
+mkdir -p ~/bin
+<span class="org-builtin">cd</span> ~/bin
ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs
- <span style="color: #b22222;"># </span><span style="color: #b22222;">(then add ~/bin to your $PATH if it's not there already)
-</span></pre>
-
+ <span class="org-comment-delimiter"># </span><span class="org-comment">(then add ~/bin to your $PATH if it's not there already)</span>
+</pre>
</div>
</div>
-<div id="outline-container-1_4" class="outline-3">
-<h3 id="sec-1_4"><span class="section-number-3">1.4</span> Usage </h3>
-<div class="outline-text-3" id="text-1_4">
+<div id="outline-container-1-4" class="outline-3">
+<h3 id="sec-1-4"><span class="section-number-3">1.4</span> Usage </h3>
+<div class="outline-text-3" id="text-1-4">
<p>
@@ -384,7 +385,6 @@ <h3 id="sec-1_4"><span class="section-number-3">1.4</span> Usage </h3>
</pre>
-
<p>
<code>filename</code> should be the last argument and should name the file from which
to read the JavaScript code. If you don't specify it, it will read code
@@ -394,183 +394,161 @@ <h3 id="sec-1_4"><span class="section-number-3">1.4</span> Usage </h3>
Supported options:
</p>
<ul>
-<li>
-<code>-b</code> or <code>--beautify</code> &mdash; output indented code; when passed, additional
-options control the beautifier:
+<li><code>-b</code> or <code>--beautify</code> &mdash; output indented code; when passed, additional
+ options control the beautifier:
<ul>
-<li>
-<code>-i N</code> or <code>--indent N</code> &mdash; indentation level (number of spaces)
+<li><code>-i N</code> or <code>--indent N</code> &mdash; indentation level (number of spaces)
</li>
-<li>
-<code>-q</code> or <code>--quote-keys</code> &mdash; quote keys in literal objects (by default,
-only keys that cannot be identifier names will be quotes).
+<li><code>-q</code> or <code>--quote-keys</code> &mdash; quote keys in literal objects (by default,
+ only keys that cannot be identifier names will be quotes).
</li>
</ul>
+
+</li>
+<li><code>--ascii</code> &mdash; pass this argument to encode non-ASCII characters as
+ <code>\uXXXX</code> sequences. By default UglifyJS won't bother to do it and will
+ output Unicode characters instead. (the output is always encoded in UTF8,
+ but if you pass this option you'll only get ASCII).
+
</li>
-<li>
-<code>--ascii</code> &mdash; pass this argument to encode non-ASCII characters as
-<code>\uXXXX</code> sequences. By default UglifyJS won't bother to do it and will
-output Unicode characters instead. (the output is always encoded in UTF8,
-but if you pass this option you'll only get ASCII).
+<li><code>-nm</code> or <code>--no-mangle</code> &mdash; don't mangle names.
</li>
-<li>
-<code>-nm</code> or <code>--no-mangle</code> &mdash; don't mangle variable names
+<li><code>-nmf</code> or <code>--no-mangle-functions</code> &ndash; in case you want to mangle variable
+ names, but not touch function names.
</li>
-<li>
-<code>-ns</code> or <code>--no-squeeze</code> &mdash; don't call <code>ast_squeeze()</code> (which does various
-optimizations that result in smaller, less readable code).
+<li><code>-ns</code> or <code>--no-squeeze</code> &mdash; don't call <code>ast_squeeze()</code> (which does various
+ optimizations that result in smaller, less readable code).
</li>
-<li>
-<code>-mt</code> or <code>--mangle-toplevel</code> &mdash; mangle names in the toplevel scope too
-(by default we don't do this).
+<li><code>-mt</code> or <code>--mangle-toplevel</code> &mdash; mangle names in the toplevel scope too
+ (by default we don't do this).
</li>
-<li>
-<code>--no-seqs</code> &mdash; when <code>ast_squeeze()</code> is called (thus, unless you pass
-<code>--no-squeeze</code>) it will reduce consecutive statements in blocks into a
-sequence. For example, "a = 10; b = 20; foo();" will be written as
-"a=10,b=20,foo();". In various occasions, this allows us to discard the
-block brackets (since the block becomes a single statement). This is ON
-by default because it seems safe and saves a few hundred bytes on some
-libs that I tested it on, but pass <code>--no-seqs</code> to disable it.
+<li><code>--no-seqs</code> &mdash; when <code>ast_squeeze()</code> is called (thus, unless you pass
+ <code>--no-squeeze</code>) it will reduce consecutive statements in blocks into a
+ sequence. For example, "a = 10; b = 20; foo();" will be written as
+ "a=10,b=20,foo();". In various occasions, this allows us to discard the
+ block brackets (since the block becomes a single statement). This is ON
+ by default because it seems safe and saves a few hundred bytes on some
+ libs that I tested it on, but pass <code>--no-seqs</code> to disable it.
</li>
-<li>
-<code>--no-dead-code</code> &mdash; by default, UglifyJS will remove code that is
-obviously unreachable (code that follows a <code>return</code>, <code>throw</code>, <code>break</code> or
-<code>continue</code> statement and is not a function/variable declaration). Pass
-this option to disable this optimization.
+<li><code>--no-dead-code</code> &mdash; by default, UglifyJS will remove code that is
+ obviously unreachable (code that follows a <code>return</code>, <code>throw</code>, <code>break</code> or
+ <code>continue</code> statement and is not a function/variable declaration). Pass
+ this option to disable this optimization.
</li>
-<li>
-<code>-nc</code> or <code>--no-copyright</code> &mdash; by default, <code>uglifyjs</code> will keep the initial
-comment tokens in the generated code (assumed to be copyright information
-etc.). If you pass this it will discard it.
+<li><code>-nc</code> or <code>--no-copyright</code> &mdash; by default, <code>uglifyjs</code> will keep the initial
+ comment tokens in the generated code (assumed to be copyright information
+ etc.). If you pass this it will discard it.
</li>
-<li>
-<code>-o filename</code> or <code>--output filename</code> &mdash; put the result in <code>filename</code>. If
-this isn't given, the result goes to standard output (or see next one).
+<li><code>-o filename</code> or <code>--output filename</code> &mdash; put the result in <code>filename</code>. If
+ this isn't given, the result goes to standard output (or see next one).
</li>
-<li>
-<code>--overwrite</code> &mdash; if the code is read from a file (not from STDIN) and you
-pass <code>--overwrite</code> then the output will be written in the same file.
+<li><code>--overwrite</code> &mdash; if the code is read from a file (not from STDIN) and you
+ pass <code>--overwrite</code> then the output will be written in the same file.
</li>
-<li>
-<code>--ast</code> &mdash; pass this if you want to get the Abstract Syntax Tree instead
-of JavaScript as output. Useful for debugging or learning more about the
-internals.
+<li><code>--ast</code> &mdash; pass this if you want to get the Abstract Syntax Tree instead
+ of JavaScript as output. Useful for debugging or learning more about the
+ internals.
</li>
-<li>
-<code>-v</code> or <code>--verbose</code> &mdash; output some notes on STDERR (for now just how long
-each operation takes).
+<li><code>-v</code> or <code>--verbose</code> &mdash; output some notes on STDERR (for now just how long
+ each operation takes).
</li>
-<li>
-<code>-d SYMBOL[=VALUE]</code> or <code>--define SYMBOL[=VALUE]</code> &mdash; will replace
-all instances of the specified symbol where used as an identifier
-(except where symbol has properly declared by a var declaration or
-use as function parameter or similar) with the specified value. This
-argument may be specified multiple times to define multiple
-symbols - if no value is specified the symbol will be replaced with
-the value <code>true</code>, or you can specify a numeric value (such as
-<code>1024</code>), a quoted string value (such as ="object"= or
-='https://github.com'<code>), or the name of another symbol or keyword (such as =null</code> or <code>document</code>).
-This allows you, for example, to assign meaningful names to key
-constant values but discard the symbolic names in the uglified
-version for brevity/efficiency, or when used wth care, allows
-UglifyJS to operate as a form of <b>conditional compilation</b>
-whereby defining appropriate values may, by dint of the constant
-folding and dead code removal features above, remove entire
-superfluous code blocks (e.g. completely remove instrumentation or
-trace code for production use).
-Where string values are being defined, the handling of quotes are
-likely to be subject to the specifics of your command shell
-environment, so you may need to experiment with quoting styles
-depending on your platform, or you may find the option
-<code>--define-from-module</code> more suitable for use.
+<li><code>-d SYMBOL[=VALUE]</code> or <code>--define SYMBOL[=VALUE]</code> &mdash; will replace
+ all instances of the specified symbol where used as an identifier
+ (except where symbol has properly declared by a var declaration or
+ use as function parameter or similar) with the specified value. This
+ argument may be specified multiple times to define multiple
+ symbols - if no value is specified the symbol will be replaced with
+ the value <code>true</code>, or you can specify a numeric value (such as
+ <code>1024</code>), a quoted string value (such as ="object"= or
+ ='https://github.com'<code>), or the name of another symbol or keyword (such as =null</code> or <code>document</code>).
+ This allows you, for example, to assign meaningful names to key
+ constant values but discard the symbolic names in the uglified
+ version for brevity/efficiency, or when used wth care, allows
+ UglifyJS to operate as a form of <b>conditional compilation</b>
+ whereby defining appropriate values may, by dint of the constant
+ folding and dead code removal features above, remove entire
+ superfluous code blocks (e.g. completely remove instrumentation or
+ trace code for production use).
+ Where string values are being defined, the handling of quotes are
+ likely to be subject to the specifics of your command shell
+ environment, so you may need to experiment with quoting styles
+ depending on your platform, or you may find the option
+ <code>--define-from-module</code> more suitable for use.
</li>
-<li>
-<code>-define-from-module SOMEMODULE</code> &mdash; will load the named module (as
-per the NodeJS <code>require()</code> function) and iterate all the exported
-properties of the module defining them as symbol names to be defined
-(as if by the <code>--define</code> option) per the name of each property
-(i.e. without the module name prefix) and given the value of the
-property. This is a much easier way to handle and document groups of
-symbols to be defined rather than a large number of <code>--define</code>
-options.
+<li><code>-define-from-module SOMEMODULE</code> &mdash; will load the named module (as
+ per the NodeJS <code>require()</code> function) and iterate all the exported
+ properties of the module defining them as symbol names to be defined
+ (as if by the <code>--define</code> option) per the name of each property
+ (i.e. without the module name prefix) and given the value of the
+ property. This is a much easier way to handle and document groups of
+ symbols to be defined rather than a large number of <code>--define</code>
+ options.
</li>
-<li>
-<code>--unsafe</code> &mdash; enable other additional optimizations that are known to be
-unsafe in some contrived situations, but could still be generally useful.
-For now only these:
+<li><code>--unsafe</code> &mdash; enable other additional optimizations that are known to be
+ unsafe in some contrived situations, but could still be generally useful.
+ For now only these:
<ul>
-<li>
-foo.toString() ==&gt; foo+""
+<li>foo.toString() ==&gt; foo+""
</li>
-<li>
-new Array(x,&hellip;) ==&gt; [x,&hellip;]
+<li>new Array(x,&hellip;) ==&gt; [x,&hellip;]
</li>
-<li>
-new Array(x) ==&gt; Array(x)
+<li>new Array(x) ==&gt; Array(x)
</li>
</ul>
+
</li>
-<li>
-<code>--max-line-len</code> (default 32K characters) &mdash; add a newline after around
-32K characters. I've seen both FF and Chrome croak when all the code was
-on a single line of around 670K. Pass &ndash;max-line-len 0 to disable this
-safety feature.
+<li><code>--max-line-len</code> (default 32K characters) &mdash; add a newline after around
+ 32K characters. I've seen both FF and Chrome croak when all the code was
+ on a single line of around 670K. Pass &ndash;max-line-len 0 to disable this
+ safety feature.
</li>
-<li>
-<code>--reserved-names</code> &mdash; some libraries rely on certain names to be used, as
-pointed out in issue #92 and #81, so this option allow you to exclude such
-names from the mangler. For example, to keep names <code>require</code> and <code>$super</code>
-intact you'd specify &ndash;reserved-names "require,$super".
+<li><code>--reserved-names</code> &mdash; some libraries rely on certain names to be used, as
+ pointed out in issue #92 and #81, so this option allow you to exclude such
+ names from the mangler. For example, to keep names <code>require</code> and <code>$super</code>
+ intact you'd specify &ndash;reserved-names "require,$super".
</li>
-<li>
-<code>--inline-script</code> &ndash; when you want to include the output literally in an
-HTML <code>&lt;script&gt;</code> tag you can use this option to prevent <code>&lt;/script</code> from
-showing up in the output.
+<li><code>--inline-script</code> &ndash; when you want to include the output literally in an
+ HTML <code>&lt;script&gt;</code> tag you can use this option to prevent <code>&lt;/script</code> from
+ showing up in the output.
</li>
-<li>
-<code>--lift-vars</code> &ndash; when you pass this, UglifyJS will apply the following
-transformations (see the notes in API, <code>ast_lift_variables</code>):
+<li><code>--lift-vars</code> &ndash; when you pass this, UglifyJS will apply the following
+ transformations (see the notes in API, <code>ast_lift_variables</code>):
<ul>
-<li>
-put all <code>var</code> declarations at the start of the scope
+<li>put all <code>var</code> declarations at the start of the scope
</li>
-<li>
-make sure a variable is declared only once
+<li>make sure a variable is declared only once
</li>
-<li>
-discard unused function arguments
+<li>discard unused function arguments
</li>
-<li>
-discard unused inner (named) functions
+<li>discard unused inner (named) functions
</li>
-<li>
-finally, try to merge assignments into that one <code>var</code> declaration, if
-possible.
+<li>finally, try to merge assignments into that one <code>var</code> declaration, if
+ possible.
</li>
</ul>
+
</li>
</ul>
@@ -578,9 +556,9 @@ <h3 id="sec-1_4"><span class="section-number-3">1.4</span> Usage </h3>
</div>
-<div id="outline-container-1_4_1" class="outline-4">
-<h4 id="sec-1_4_1"><span class="section-number-4">1.4.1</span> API </h4>
-<div class="outline-text-4" id="text-1_4_1">
+<div id="outline-container-1-4-1" class="outline-4">
+<h4 id="sec-1-4-1"><span class="section-number-4">1.4.1</span> API </h4>
+<div class="outline-text-4" id="text-1-4-1">
<p>
@@ -590,16 +568,15 @@ <h4 id="sec-1_4_1"><span class="section-number-4">1.4.1</span> API </h4>
-<pre class="src src-js"><span style="color: #a020f0;">var</span> <span style="color: #b8860b;">jsp</span> = require(<span style="color: #bc8f8f;">"uglify-js"</span>).parser;
-<span style="color: #a020f0;">var</span> <span style="color: #b8860b;">pro</span> = require(<span style="color: #bc8f8f;">"uglify-js"</span>).uglify;
-
-<span style="color: #a020f0;">var</span> <span style="color: #b8860b;">orig_code</span> = <span style="color: #bc8f8f;">"... JS code here"</span>;
-<span style="color: #a020f0;">var</span> <span style="color: #b8860b;">ast</span> = jsp.parse(orig_code); <span style="color: #b22222;">// </span><span style="color: #b22222;">parse code and get the initial AST
-</span>ast = pro.ast_mangle(ast); <span style="color: #b22222;">// </span><span style="color: #b22222;">get a new AST with mangled names
-</span>ast = pro.ast_squeeze(ast); <span style="color: #b22222;">// </span><span style="color: #b22222;">get an AST with compression optimizations
-</span><span style="color: #a020f0;">var</span> <span style="color: #b8860b;">final_code</span> = pro.gen_code(ast); <span style="color: #b22222;">// </span><span style="color: #b22222;">compressed code here
-</span></pre>
+<pre class="src src-js"><span class="org-keyword">var</span> <span class="org-variable-name">jsp</span> = require(<span class="org-string">"uglify-js"</span>).parser;
+<span class="org-keyword">var</span> <span class="org-variable-name">pro</span> = require(<span class="org-string">"uglify-js"</span>).uglify;
+<span class="org-keyword">var</span> <span class="org-variable-name">orig_code</span> = <span class="org-string">"... JS code here"</span>;
+<span class="org-keyword">var</span> <span class="org-variable-name">ast</span> = jsp.parse(orig_code); <span class="org-comment-delimiter">// </span><span class="org-comment">parse code and get the initial AST</span>
+ast = pro.ast_mangle(ast); <span class="org-comment-delimiter">// </span><span class="org-comment">get a new AST with mangled names</span>
+ast = pro.ast_squeeze(ast); <span class="org-comment-delimiter">// </span><span class="org-comment">get an AST with compression optimizations</span>
+<span class="org-keyword">var</span> <span class="org-variable-name">final_code</span> = pro.gen_code(ast); <span class="org-comment-delimiter">// </span><span class="org-comment">compressed code here</span>
+</pre>
<p>
@@ -613,150 +590,135 @@ <h4 id="sec-1_4_1"><span class="section-number-4">1.4.1</span> API </h4>
Some of these functions take optional arguments. Here's a description:
</p>
<ul>
-<li>
-<code>jsp.parse(code, strict_semicolons)</code> &ndash; parses JS code and returns an AST.
-<code>strict_semicolons</code> is optional and defaults to <code>false</code>. If you pass
-<code>true</code> then the parser will throw an error when it expects a semicolon and
-it doesn't find it. For most JS code you don't want that, but it's useful
-if you want to strictly sanitize your code.
+<li><code>jsp.parse(code, strict_semicolons)</code> &ndash; parses JS code and returns an AST.
+ <code>strict_semicolons</code> is optional and defaults to <code>false</code>. If you pass
+ <code>true</code> then the parser will throw an error when it expects a semicolon and
+ it doesn't find it. For most JS code you don't want that, but it's useful
+ if you want to strictly sanitize your code.
</li>
-<li>
-<code>pro.ast_lift_variables(ast)</code> &ndash; merge and move <code>var</code> declarations to the
-scop of the scope; discard unused function arguments or variables; discard
-unused (named) inner functions. It also tries to merge assignments
-following the <code>var</code> declaration into it.
+<li><code>pro.ast_lift_variables(ast)</code> &ndash; merge and move <code>var</code> declarations to the
+ scop of the scope; discard unused function arguments or variables; discard
+ unused (named) inner functions. It also tries to merge assignments
+ following the <code>var</code> declaration into it.
<p>
-If your code is very hand-optimized concerning <code>var</code> declarations, this
-lifting variable declarations might actually increase size. For me it
-helps out. On jQuery it adds 865 bytes (243 after gzip). YMMV. Also
-note that (since it's not enabled by default) this operation isn't yet
-heavily tested (please report if you find issues!).
+ If your code is very hand-optimized concerning <code>var</code> declarations, this
+ lifting variable declarations might actually increase size. For me it
+ helps out. On jQuery it adds 865 bytes (243 after gzip). YMMV. Also
+ note that (since it's not enabled by default) this operation isn't yet
+ heavily tested (please report if you find issues!).
</p>
<p>
-Note that although it might increase the image size (on jQuery it gains
-865 bytes, 243 after gzip) it's technically more correct: in certain
-situations, dead code removal might drop variable declarations, which
-would not happen if the variables are lifted in advance.
+ Note that although it might increase the image size (on jQuery it gains
+ 865 bytes, 243 after gzip) it's technically more correct: in certain
+ situations, dead code removal might drop variable declarations, which
+ would not happen if the variables are lifted in advance.
</p>
<p>
-Here's an example of what it does:
-</p>
-</li>
+ Here's an example of what it does:
+</p></li>
</ul>
-<pre class="src src-js"><span style="color: #a020f0;">function</span> <span style="color: #0000ff;">f</span>(<span style="color: #b8860b;">a</span>, <span style="color: #b8860b;">b</span>, <span style="color: #b8860b;">c</span>, <span style="color: #b8860b;">d</span>, <span style="color: #b8860b;">e</span>) {
- <span style="color: #a020f0;">var</span> <span style="color: #b8860b;">q</span>;
- <span style="color: #a020f0;">var</span> <span style="color: #b8860b;">w</span>;
+
+<pre class="src src-js"><span class="org-keyword">function</span> <span class="org-function-name">f</span>(<span class="org-variable-name">a</span>, <span class="org-variable-name">b</span>, <span class="org-variable-name">c</span>, <span class="org-variable-name">d</span>, <span class="org-variable-name">e</span>) {
+ <span class="org-keyword">var</span> <span class="org-variable-name">q</span>;
+ <span class="org-keyword">var</span> <span class="org-variable-name">w</span>;
w = 10;
q = 20;
- <span style="color: #a020f0;">for</span> (<span style="color: #a020f0;">var</span> <span style="color: #b8860b;">i</span> = 1; i &lt; 10; ++i) {
- <span style="color: #a020f0;">var</span> <span style="color: #b8860b;">boo</span> = foo(a);
+ <span class="org-keyword">for</span> (<span class="org-keyword">var</span> <span class="org-variable-name">i</span> = 1; i &lt; 10; ++i) {
+ <span class="org-keyword">var</span> <span class="org-variable-name">boo</span> = foo(a);
}
- <span style="color: #a020f0;">for</span> (<span style="color: #a020f0;">var</span> <span style="color: #b8860b;">i</span> = 0; i &lt; 1; ++i) {
- <span style="color: #a020f0;">var</span> <span style="color: #b8860b;">boo</span> = bar(c);
+ <span class="org-keyword">for</span> (<span class="org-keyword">var</span> <span class="org-variable-name">i</span> = 0; i &lt; 1; ++i) {
+ <span class="org-keyword">var</span> <span class="org-variable-name">boo</span> = bar(c);
}
- <span style="color: #a020f0;">function</span> <span style="color: #0000ff;">foo</span>(){ ... }
- <span style="color: #a020f0;">function</span> <span style="color: #0000ff;">bar</span>(){ ... }
- <span style="color: #a020f0;">function</span> <span style="color: #0000ff;">baz</span>(){ ... }
+ <span class="org-keyword">function</span> <span class="org-function-name">foo</span>(){ ... }
+ <span class="org-keyword">function</span> <span class="org-function-name">bar</span>(){ ... }
+ <span class="org-keyword">function</span> <span class="org-function-name">baz</span>(){ ... }
}
-<span style="color: #b22222;">// </span><span style="color: #b22222;">transforms into ==&gt;
-</span>
-<span style="color: #a020f0;">function</span> <span style="color: #0000ff;">f</span>(<span style="color: #b8860b;">a</span>, <span style="color: #b8860b;">b</span>, <span style="color: #b8860b;">c</span>) {
- <span style="color: #a020f0;">var</span> <span style="color: #b8860b;">i</span>, <span style="color: #b8860b;">boo</span>, <span style="color: #b8860b;">w</span> = 10, <span style="color: #b8860b;">q</span> = 20;
- <span style="color: #a020f0;">for</span> (i = 1; i &lt; 10; ++i) {
+<span class="org-comment-delimiter">// </span><span class="org-comment">transforms into ==&gt;</span>
+
+<span class="org-keyword">function</span> <span class="org-function-name">f</span>(<span class="org-variable-name">a</span>, <span class="org-variable-name">b</span>, <span class="org-variable-name">c</span>) {
+ <span class="org-keyword">var</span> <span class="org-variable-name">i</span>, <span class="org-variable-name">boo</span>, <span class="org-variable-name">w</span> = 10, <span class="org-variable-name">q</span> = 20;
+ <span class="org-keyword">for</span> (i = 1; i &lt; 10; ++i) {
boo = foo(a);
}
- <span style="color: #a020f0;">for</span> (i = 0; i &lt; 1; ++i) {
+ <span class="org-keyword">for</span> (i = 0; i &lt; 1; ++i) {
boo = bar(c);
}
- <span style="color: #a020f0;">function</span> <span style="color: #0000ff;">foo</span>() { ... }
- <span style="color: #a020f0;">function</span> <span style="color: #0000ff;">bar</span>() { ... }
+ <span class="org-keyword">function</span> <span class="org-function-name">foo</span>() { ... }
+ <span class="org-keyword">function</span> <span class="org-function-name">bar</span>() { ... }
}
</pre>
-
<ul>
-<li>
-<code>pro.ast_mangle(ast, options)</code> &ndash; generates a new AST containing mangled
-(compressed) variable and function names. It supports the following
-options:
+<li><code>pro.ast_mangle(ast, options)</code> &ndash; generates a new AST containing mangled
+ (compressed) variable and function names. It supports the following
+ options:
<ul>
-<li>
-<code>toplevel</code> &ndash; mangle toplevel names (by default we don't touch them).
+<li><code>toplevel</code> &ndash; mangle toplevel names (by default we don't touch them).
</li>
-<li>
-<code>except</code> &ndash; an array of names to exclude from compression.
+<li><code>except</code> &ndash; an array of names to exclude from compression.
</li>
-<li>
-<code>defines</code> &ndash; an object with properties named after symbols to
-replace (see the <code>--define</code> option for the script) and the values
-representing the AST replacement value.
+<li><code>defines</code> &ndash; an object with properties named after symbols to
+ replace (see the <code>--define</code> option for the script) and the values
+ representing the AST replacement value.
</li>
</ul>
+
</li>
-<li>
-<code>pro.ast_squeeze(ast, options)</code> &ndash; employs further optimizations designed
-to reduce the size of the code that <code>gen_code</code> would generate from the
-AST. Returns a new AST. <code>options</code> can be a hash; the supported options
-are:
+<li><code>pro.ast_squeeze(ast, options)</code> &ndash; employs further optimizations designed
+ to reduce the size of the code that <code>gen_code</code> would generate from the
+ AST. Returns a new AST. <code>options</code> can be a hash; the supported options
+ are:
<ul>
-<li>
-<code>make_seqs</code> (default true) which will cause consecutive statements in a
-block to be merged using the "sequence" (comma) operator
+<li><code>make_seqs</code> (default true) which will cause consecutive statements in a
+ block to be merged using the "sequence" (comma) operator
</li>
-<li>
-<code>dead_code</code> (default true) which will remove unreachable code.
+<li><code>dead_code</code> (default true) which will remove unreachable code.
</li>
</ul>
+
</li>
-<li>
-<code>pro.gen_code(ast, options)</code> &ndash; generates JS code from the AST. By
-default it's minified, but using the <code>options</code> argument you can get nicely
-formatted output. <code>options</code> is, well, optional :-) and if you pass it it
-must be an object and supports the following properties (below you can see
-the default values):
+<li><code>pro.gen_code(ast, options)</code> &ndash; generates JS code from the AST. By
+ default it's minified, but using the <code>options</code> argument you can get nicely
+ formatted output. <code>options</code> is, well, optional :-) and if you pass it it
+ must be an object and supports the following properties (below you can see
+ the default values):
<ul>
-<li>
-<code>beautify: false</code> &ndash; pass <code>true</code> if you want indented output
+<li><code>beautify: false</code> &ndash; pass <code>true</code> if you want indented output
</li>
-<li>
-<code>indent_start: 0</code> (only applies when <code>beautify</code> is <code>true</code>) &ndash; initial
-indentation in spaces
+<li><code>indent_start: 0</code> (only applies when <code>beautify</code> is <code>true</code>) &ndash; initial
+ indentation in spaces
</li>
-<li>
-<code>indent_level: 4</code> (only applies when <code>beautify</code> is <code>true</code>) --
-indentation level, in spaces (pass an even number)
+<li><code>indent_level: 4</code> (only applies when <code>beautify</code> is <code>true</code>) --
+ indentation level, in spaces (pass an even number)
</li>
-<li>
-<code>quote_keys: false</code> &ndash; if you pass <code>true</code> it will quote all keys in
-literal objects
+<li><code>quote_keys: false</code> &ndash; if you pass <code>true</code> it will quote all keys in
+ literal objects
</li>
-<li>
-<code>space_colon: false</code> (only applies when <code>beautify</code> is <code>true</code>) &ndash; wether
-to put a space before the colon in object literals
+<li><code>space_colon: false</code> (only applies when <code>beautify</code> is <code>true</code>) &ndash; wether
+ to put a space before the colon in object literals
</li>
-<li>
-<code>ascii_only: false</code> &ndash; pass <code>true</code> if you want to encode non-ASCII
-characters as <code>\uXXXX</code>.
+<li><code>ascii_only: false</code> &ndash; pass <code>true</code> if you want to encode non-ASCII
+ characters as <code>\uXXXX</code>.
</li>
-<li>
-<code>inline_script: false</code> &ndash; pass <code>true</code> to escape occurrences of
-<code>&lt;/script</code> in strings
+<li><code>inline_script: false</code> &ndash; pass <code>true</code> to escape occurrences of
+ <code>&lt;/script</code> in strings
</li>
</ul>
+
</li>
</ul>
@@ -765,9 +727,9 @@ <h4 id="sec-1_4_1"><span class="section-number-4">1.4.1</span> API </h4>
</div>
-<div id="outline-container-1_4_2" class="outline-4">
-<h4 id="sec-1_4_2"><span class="section-number-4">1.4.2</span> Beautifier shortcoming &ndash; no more comments </h4>
-<div class="outline-text-4" id="text-1_4_2">
+<div id="outline-container-1-4-2" class="outline-4">
+<h4 id="sec-1-4-2"><span class="section-number-4">1.4.2</span> Beautifier shortcoming &ndash; no more comments </h4>
+<div class="outline-text-4" id="text-1-4-2">
<p>
@@ -787,9 +749,9 @@ <h4 id="sec-1_4_2"><span class="section-number-4">1.4.2</span> Beautifier shortc
</div>
-<div id="outline-container-1_4_3" class="outline-4">
-<h4 id="sec-1_4_3"><span class="section-number-4">1.4.3</span> Use as a code pre-processor </h4>
-<div class="outline-text-4" id="text-1_4_3">
+<div id="outline-container-1-4-3" class="outline-4">
+<h4 id="sec-1-4-3"><span class="section-number-4">1.4.3</span> Use as a code pre-processor </h4>
+<div class="outline-text-4" id="text-1-4-3">
<p>
@@ -806,28 +768,27 @@ <h4 id="sec-1_4_3"><span class="section-number-4">1.4.3</span> Use as a code pre
-<pre class="src src-js">CLAUSE1: <span style="color: #a020f0;">if</span> (<span style="color: #a020f0;">typeof</span> DEVMODE === <span style="color: #bc8f8f;">'undefined'</span>) {
- DEVMODE = <span style="color: #5f9ea0;">true</span>;
+<pre class="src src-js">CLAUSE1: <span class="org-keyword">if</span> (<span class="org-keyword">typeof</span> DEVMODE === <span class="org-string">'undefined'</span>) {
+ DEVMODE = <span class="org-constant">true</span>;
}
-<span style="color: #0000ff;">CLAUSE2</span>: <span style="color: #a020f0;">function</span> init() {
- <span style="color: #a020f0;">if</span> (DEVMODE) {
- console.log(<span style="color: #bc8f8f;">"init() called"</span>);
+<span class="org-function-name">CLAUSE2</span>: <span class="org-keyword">function</span> init() {
+ <span class="org-keyword">if</span> (DEVMODE) {
+ console.log(<span class="org-string">"init() called"</span>);
}
....
- DEVMODE &amp;amp;&amp;amp; console.log(<span style="color: #bc8f8f;">"init() complete"</span>);
+ DEVMODE &amp;amp;&amp;amp; console.log(<span class="org-string">"init() complete"</span>);
}
-<span style="color: #0000ff;">CLAUSE3</span>: <span style="color: #a020f0;">function</span> reportDeviceStatus(<span style="color: #b8860b;">device</span>) {
- <span style="color: #a020f0;">var</span> <span style="color: #b8860b;">DEVMODE</span> = device.mode, <span style="color: #b8860b;">DEVNAME</span> = device.name;
- <span style="color: #a020f0;">if</span> (DEVMODE === <span style="color: #bc8f8f;">'open'</span>) {
+<span class="org-function-name">CLAUSE3</span>: <span class="org-keyword">function</span> reportDeviceStatus(<span class="org-variable-name">device</span>) {
+ <span class="org-keyword">var</span> <span class="org-variable-name">DEVMODE</span> = device.mode, <span class="org-variable-name">DEVNAME</span> = device.name;
+ <span class="org-keyword">if</span> (DEVMODE === <span class="org-string">'open'</span>) {
....
}
}
</pre>
-
<p>
When the above code is normally executed, the undeclared global
variable <code>DEVMODE</code> will be assigned the value <b>true</b> (see <code>CLAUSE1</code>)
@@ -869,9 +830,9 @@ <h4 id="sec-1_4_3"><span class="section-number-4">1.4.3</span> Use as a code pre
</div>
-<div id="outline-container-1_5" class="outline-3">
-<h3 id="sec-1_5"><span class="section-number-3">1.5</span> Compression &ndash; how good is it? </h3>
-<div class="outline-text-3" id="text-1_5">
+<div id="outline-container-1-5" class="outline-3">
+<h3 id="sec-1-5"><span class="section-number-3">1.5</span> Compression &ndash; how good is it? </h3>
+<div class="outline-text-3" id="text-1-5">
<p>
@@ -885,16 +846,16 @@ <h3 id="sec-1_5"><span class="section-number-3">1.5</span> Compression &ndash; h
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<caption></caption>
-<colgroup><col align="left" /><col align="left" /><col align="right" /><col align="left" /><col align="right" /><col align="left" /><col align="right" />
+<colgroup><col class="left" /><col class="left" /><col class="right" /><col class="left" /><col class="right" /><col class="left" /><col class="right" />
</colgroup>
<thead>
-<tr><th scope="col">File</th><th scope="col">UglifyJS</th><th scope="col">UglifyJS+gzip</th><th scope="col">Closure</th><th scope="col">Closure+gzip</th><th scope="col">YUI</th><th scope="col">YUI+gzip</th></tr>
+<tr><th scope="col" class="left">File</th><th scope="col" class="left">UglifyJS</th><th scope="col" class="right">UglifyJS+gzip</th><th scope="col" class="left">Closure</th><th scope="col" class="right">Closure+gzip</th><th scope="col" class="left">YUI</th><th scope="col" class="right">YUI+gzip</th></tr>
</thead>
<tbody>
-<tr><td>jquery-1.6.2.js</td><td>91001 (0:01.59)</td><td>31896</td><td>90678 (0:07.40)</td><td>31979</td><td>101527 (0:01.82)</td><td>34646</td></tr>
-<tr><td>paper.js</td><td>142023 (0:01.65)</td><td>43334</td><td>134301 (0:07.42)</td><td>42495</td><td>173383 (0:01.58)</td><td>48785</td></tr>
-<tr><td>prototype.js</td><td>88544 (0:01.09)</td><td>26680</td><td>86955 (0:06.97)</td><td>26326</td><td>92130 (0:00.79)</td><td>28624</td></tr>
-<tr><td>thelib-full.js (DynarchLIB)</td><td>251939 (0:02.55)</td><td>72535</td><td>249911 (0:09.05)</td><td>72696</td><td>258869 (0:01.94)</td><td>76584</td></tr>
+<tr><td class="left">jquery-1.6.2.js</td><td class="left">91001 (0:01.59)</td><td class="right">31896</td><td class="left">90678 (0:07.40)</td><td class="right">31979</td><td class="left">101527 (0:01.82)</td><td class="right">34646</td></tr>
+<tr><td class="left">paper.js</td><td class="left">142023 (0:01.65)</td><td class="right">43334</td><td class="left">134301 (0:07.42)</td><td class="right">42495</td><td class="left">173383 (0:01.58)</td><td class="right">48785</td></tr>
+<tr><td class="left">prototype.js</td><td class="left">88544 (0:01.09)</td><td class="right">26680</td><td class="left">86955 (0:06.97)</td><td class="right">26326</td><td class="left">92130 (0:00.79)</td><td class="right">28624</td></tr>
+<tr><td class="left">thelib-full.js (DynarchLIB)</td><td class="left">251939 (0:02.55)</td><td class="right">72535</td><td class="left">249911 (0:09.05)</td><td class="right">72696</td><td class="left">258869 (0:01.94)</td><td class="right">76584</td></tr>
</tbody>
</table>
@@ -903,9 +864,9 @@ <h3 id="sec-1_5"><span class="section-number-3">1.5</span> Compression &ndash; h
</div>
-<div id="outline-container-1_6" class="outline-3">
-<h3 id="sec-1_6"><span class="section-number-3">1.6</span> Bugs? </h3>
-<div class="outline-text-3" id="text-1_6">
+<div id="outline-container-1-6" class="outline-3">
+<h3 id="sec-1-6"><span class="section-number-3">1.6</span> Bugs? </h3>
+<div class="outline-text-3" id="text-1-6">
<p>
@@ -929,29 +890,23 @@ <h3 id="sec-1_6"><span class="section-number-3">1.6</span> Bugs? </h3>
</div>
-<div id="outline-container-1_7" class="outline-3">
-<h3 id="sec-1_7"><span class="section-number-3">1.7</span> Links </h3>
-<div class="outline-text-3" id="text-1_7">
+<div id="outline-container-1-7" class="outline-3">
+<h3 id="sec-1-7"><span class="section-number-3">1.7</span> Links </h3>
+<div class="outline-text-3" id="text-1-7">
<ul>
-<li>
-Twitter: <a href="http://twitter.com/UglifyJS">@UglifyJS</a>
+<li>Twitter: <a href="http://twitter.com/UglifyJS">@UglifyJS</a>
</li>
-<li>
-Project at GitHub: <a href="http://github.com/mishoo/UglifyJS">http://github.com/mishoo/UglifyJS</a>
+<li>Project at GitHub: <a href="http://github.com/mishoo/UglifyJS">http://github.com/mishoo/UglifyJS</a>
</li>
-<li>
-Google Group: <a href="http://groups.google.com/group/uglifyjs">http://groups.google.com/group/uglifyjs</a>
+<li>Google Group: <a href="http://groups.google.com/group/uglifyjs">http://groups.google.com/group/uglifyjs</a>
</li>
-<li>
-Common Lisp JS parser: <a href="http://marijn.haverbeke.nl/parse-js/">http://marijn.haverbeke.nl/parse-js/</a>
+<li>Common Lisp JS parser: <a href="http://marijn.haverbeke.nl/parse-js/">http://marijn.haverbeke.nl/parse-js/</a>
</li>
-<li>
-JS-to-Lisp compiler: <a href="http://github.com/marijnh/js">http://github.com/marijnh/js</a>
+<li>JS-to-Lisp compiler: <a href="http://github.com/marijnh/js">http://github.com/marijnh/js</a>
</li>
-<li>
-Common Lisp JS uglifier: <a href="http://github.com/mishoo/cl-uglify-js">http://github.com/mishoo/cl-uglify-js</a>
+<li>Common Lisp JS uglifier: <a href="http://github.com/mishoo/cl-uglify-js">http://github.com/mishoo/cl-uglify-js</a>
</li>
</ul>
@@ -960,9 +915,9 @@ <h3 id="sec-1_7"><span class="section-number-3">1.7</span> Links </h3>
</div>
-<div id="outline-container-1_8" class="outline-3">
-<h3 id="sec-1_8"><span class="section-number-3">1.8</span> License </h3>
-<div class="outline-text-3" id="text-1_8">
+<div id="outline-container-1-8" class="outline-3">
+<h3 id="sec-1-8"><span class="section-number-3">1.8</span> License </h3>
+<div class="outline-text-3" id="text-1-8">
<p>
@@ -1002,25 +957,25 @@ <h3 id="sec-1_8"><span class="section-number-3">1.8</span> License </h3>
</pre>
-
-
-</div>
-</div>
-</div>
<div id="footnotes">
<h2 class="footnotes">Footnotes: </h2>
<div id="text-footnotes">
<p class="footnote"><sup><a class="footnum" name="fn.1" href="#fnr.1">1</a></sup> I even reported a few bugs and suggested some fixes in the original
-<a href="http://marijn.haverbeke.nl/parse-js/">parse-js</a> library, and Marijn pushed fixes literally in minutes.
-</p>
+ <a href="http://marijn.haverbeke.nl/parse-js/">parse-js</a> library, and Marijn pushed fixes literally in minutes.
+</p></div>
</div>
</div>
-<div id="postamble">
-<p class="author"> Author: Mihai Bazon
-</p>
-<p class="date"> Date: 2011-08-29 19:17:55 EEST</p>
-<p class="creator">HTML generated by org-mode 7.01trans in emacs 23</p>
+
</div>
</div>
+</div>
+
+<div id="postamble">
+<p class="date">Date: 2011-12-09 14:59:08 EET</p>
+<p class="author">Author: Mihai Bazon</p>
+<p class="creator">Org version 7.7 with Emacs version 23</p>
+<a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a>
+
+</div>
</body>
</html>
View
7 README.org
@@ -192,7 +192,10 @@ Supported options:
output Unicode characters instead. (the output is always encoded in UTF8,
but if you pass this option you'll only get ASCII).
-- =-nm= or =--no-mangle= --- don't mangle variable names
+- =-nm= or =--no-mangle= --- don't mangle names.
+
+- =-nmf= or =--no-mangle-functions= -- in case you want to mangle variable
+ names, but not touch function names.
- =-ns= or =--no-squeeze= --- don't call =ast_squeeze()= (which does various
optimizations that result in smaller, less readable code).
@@ -239,7 +242,7 @@ Supported options:
the value =true=, or you can specify a numeric value (such as
=1024=), a quoted string value (such as ="object"= or
='https://github.com'=), or the name of another symbol or keyword
- (such as =null= or =document=).
+ (such as =null= or =document=).
This allows you, for example, to assign meaningful names to key
constant values but discard the symbolic names in the uglified
version for brevity/efficiency, or when used wth care, allows
Please sign in to comment.
Something went wrong with that request. Please try again.