/node_modules/require/node_modules/uglify-js/package.json

https://bitbucket.org/gagginaspinnata/todo-app-with-angularjs · JSON · 24 lines · 24 code · 0 blank · 0 comment · 0 complexity · 4829a94ec946a9b09c8cce0c5ab5c18c MD5 · raw file

  1. {
  2. "name": "uglify-js",
  3. "author": {
  4. "name": "Mihai Bazon",
  5. "email": "mihai.bazon@gmail.com",
  6. "url": "http://mihai.bazon.net/blog"
  7. },
  8. "version": "1.0.3",
  9. "main": "./uglify-js.js",
  10. "bin": {
  11. "uglifyjs": "./bin/uglifyjs"
  12. },
  13. "repository": {
  14. "type": "git",
  15. "url": "git@github.com:mishoo/UglifyJS.git"
  16. },
  17. "readme": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\"\nlang=\"en\" xml:lang=\"en\">\n<head>\n<title>UglifyJS -- a JavaScript parser/compressor/beautifier</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>\n<meta name=\"generator\" content=\"Org-mode\"/>\n<meta name=\"generated\" content=\"2011-04-04 00:07:13 EEST\"/>\n<meta name=\"author\" content=\"Mihai Bazon\"/>\n<meta name=\"description\" content=\"a JavaScript parser/compressor/beautifier in JavaScript\"/>\n<meta name=\"keywords\" content=\"javascript, js, parser, compiler, compressor, mangle, minify, minifier\"/>\n<style type=\"text/css\">\n <!--/*--><![CDATA[/*><!--*/\n html { font-family: Times, serif; font-size: 12pt; }\n .title { text-align: center; }\n .todo { color: red; }\n .done { color: green; }\n .tag { background-color: #add8e6; font-weight:normal }\n .target { }\n .timestamp { color: #bebebe; }\n .timestamp-kwd { color: #5f9ea0; }\n p.verse { margin-left: 3% }\n pre {\n\tborder: 1pt solid #AEBDCC;\n\tbackground-color: #F3F5F7;\n\tpadding: 5pt;\n\tfont-family: courier, monospace;\n font-size: 90%;\n overflow:auto;\n }\n table { border-collapse: collapse; }\n td, th { vertical-align: top; }\n dt { font-weight: bold; }\n div.figure { padding: 0.5em; }\n div.figure p { text-align: center; }\n textarea { overflow-x: auto; }\n .linenr { font-size:smaller }\n .code-highlighted {background-color:#ffff00;}\n .org-info-js_info-navigation { border-style:none; }\n #org-info-js_console-label { font-size:10px; font-weight:bold;\n white-space:nowrap; }\n .org-info-js_search-highlight {background-color:#ffff00; color:#000000;\n font-weight:bold; }\n /*]]>*/-->\n</style>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"docstyle.css\" />\n<script type=\"text/javascript\">\n<!--/*--><![CDATA[/*><!--*/\n function CodeHighlightOn(elem, id)\n {\n var target = document.getElementById(id);\n if(null != target) {\n elem.cacheClassElem = elem.className;\n elem.cacheClassTarget = target.className;\n target.className = \"code-highlighted\";\n elem.className = \"code-highlighted\";\n }\n }\n function CodeHighlightOff(elem, id)\n {\n var target = document.getElementById(id);\n if(elem.cacheClassElem)\n elem.className = elem.cacheClassElem;\n if(elem.cacheClassTarget)\n target.className = elem.cacheClassTarget;\n }\n/*]]>*///-->\n</script>\n\n</head>\n<body>\n<div id=\"content\">\n\n<h1 class=\"title\">UglifyJS &ndash; a JavaScript parser/compressor/beautifier</h1>\n\n\n<div id=\"table-of-contents\">\n<h2>Table of Contents</h2>\n<div id=\"text-table-of-contents\">\n<ul>\n<li><a href=\"#sec-1\">1 UglifyJS &mdash; a JavaScript parser/compressor/beautifier </a>\n<ul>\n<li><a href=\"#sec-1_1\">1.1 Unsafe transformations </a>\n<ul>\n<li><a href=\"#sec-1_1_1\">1.1.1 Calls involving the global Array constructor </a></li>\n</ul>\n</li>\n<li><a href=\"#sec-1_2\">1.2 Install (NPM) </a></li>\n<li><a href=\"#sec-1_3\">1.3 Install latest code from GitHub </a></li>\n<li><a href=\"#sec-1_4\">1.4 Usage </a>\n<ul>\n<li><a href=\"#sec-1_4_1\">1.4.1 API </a></li>\n<li><a href=\"#sec-1_4_2\">1.4.2 Beautifier shortcoming &ndash; no more comments </a></li>\n</ul>\n</li>\n<li><a href=\"#sec-1_5\">1.5 Compression &ndash; how good is it? </a></li>\n<li><a href=\"#sec-1_6\">1.6 Bugs? </a></li>\n<li><a href=\"#sec-1_7\">1.7 Links </a></li>\n<li><a href=\"#sec-1_8\">1.8 License </a></li>\n</ul>\n</li>\n</ul>\n</div>\n</div>\n\n<div id=\"outline-container-1\" class=\"outline-2\">\n<h2 id=\"sec-1\"><span class=\"section-number-2\">1</span> UglifyJS &mdash; a JavaScript parser/compressor/beautifier </h2>\n<div class=\"outline-text-2\" id=\"text-1\">\n\n\n<p>\nThis package implements a general-purpose JavaScript\nparser/compressor/beautifier toolkit. It is developed on <a href=\"http://nodejs.org/\">NodeJS</a>, but it\nshould work on any JavaScript platform supporting the CommonJS module system\n(and if your platform of choice doesn't support CommonJS, you can easily\nimplement it, or discard the <code>exports.*</code> lines from UglifyJS sources).\n</p>\n<p>\nThe tokenizer/parser generates an abstract syntax tree from JS code. You\ncan then traverse the AST to learn more about the code, or do various\nmanipulations on it. This part is implemented in <a href=\"../lib/parse-js.js\">parse-js.js</a> and it's a\nport to JavaScript of the excellent <a href=\"http://marijn.haverbeke.nl/parse-js/\">parse-js</a> Common Lisp library from <a href=\"http://marijn.haverbeke.nl/\">Marijn Haverbeke</a>.\n</p>\n<p>\n( See <a href=\"http://github.com/mishoo/cl-uglify-js\">cl-uglify-js</a> if you're looking for the Common Lisp version of\nUglifyJS. )\n</p>\n<p>\nThe second part of this package, implemented in <a href=\"../lib/process.js\">process.js</a>, inspects and\nmanipulates the AST generated by the parser to provide the following:\n</p>\n<ul>\n<li>\nability to re-generate JavaScript code from the AST. Optionally\nindented&mdash;you can use this if you want to “beautify” a program that has\nbeen compressed, so that you can inspect the source. But you can also run\nour code generator to print out an AST without any whitespace, so you\nachieve compression as well.\n\n</li>\n<li>\nshorten variable names (usually to single characters). Our mangler will\nanalyze the code and generate proper variable names, depending on scope\nand usage, and is smart enough to deal with globals defined elsewhere, or\nwith <code>eval()</code> calls or <code>with{}</code> statements. In short, if <code>eval()</code> or\n<code>with{}</code> are used in some scope, then all variables in that scope and any\nvariables in the parent scopes will remain unmangled, and any references\nto such variables remain unmangled as well.\n\n</li>\n<li>\nvarious small optimizations that may lead to faster code but certainly\nlead to smaller code. Where possible, we do the following:\n\n<ul>\n<li>\nfoo[\"bar\"] ==&gt; foo.bar\n\n</li>\n<li>\nremove block brackets <code>{}</code>\n\n</li>\n<li>\njoin consecutive var declarations:\nvar a = 10; var b = 20; ==&gt; var a=10,b=20;\n\n</li>\n<li>\nresolve simple constant expressions: 1 +2 * 3 ==&gt; 7. We only do the\nreplacement if the result occupies less bytes; for example 1/3 would\ntranslate to 0.333333333333, so in this case we don't replace it.\n\n</li>\n<li>\nconsecutive statements in blocks are merged into a sequence; in many\ncases, this leaves blocks with a single statement, so then we can remove\nthe block brackets.\n\n</li>\n<li>\nvarious optimizations for IF statements:\n\n<ul>\n<li>\nif (foo) bar(); else baz(); ==&gt; foo?bar():baz();\n</li>\n<li>\nif (!foo) bar(); else baz(); ==&gt; foo?baz():bar();\n</li>\n<li>\nif (foo) bar(); ==&gt; foo&amp;&amp;bar();\n</li>\n<li>\nif (!foo) bar(); ==&gt; foo||bar();\n</li>\n<li>\nif (foo) return bar(); else return baz(); ==&gt; return foo?bar():baz();\n</li>\n<li>\nif (foo) return bar(); else something(); ==&gt; {if(foo)return bar();something()}\n\n</li>\n</ul>\n</li>\n<li>\nremove some unreachable code and warn about it (code that follows a\n<code>return</code>, <code>throw</code>, <code>break</code> or <code>continue</code> statement, except\nfunction/variable declarations).\n</li>\n</ul>\n</li>\n</ul>\n\n\n\n</div>\n\n<div id=\"outline-container-1_1\" class=\"outline-3\">\n<h3 id=\"sec-1_1\"><span class=\"section-number-3\">1.1</span> <span class=\"target\">Unsafe transformations</span> </h3>\n<div class=\"outline-text-3\" id=\"text-1_1\">\n\n\n<p>\nUglifyJS tries its best to achieve great compression while leaving the\nsemantics of the code intact. In general, if your code logic is broken by\nUglifyJS then it's a bug in UglifyJS and you should report it and I should\nfix it. :-)\n</p>\n<p>\nHowever, I opted to include the following potentially unsafe transformations\nas default behavior. Discussion is welcome, if you have ideas of how to\nhandle this better, or any objections to these optimizations, please let me\nknow.\n</p>\n\n</div>\n\n<div id=\"outline-container-1_1_1\" class=\"outline-4\">\n<h4 id=\"sec-1_1_1\"><span class=\"section-number-4\">1.1.1</span> Calls involving the global Array constructor </h4>\n<div class=\"outline-text-4\" id=\"text-1_1_1\">\n\n\n<p>\nThe following transformations occur:\n</p>\n\n\n\n<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]\nArray(a, b, c) =&gt; [a,b,c]\n<span style=\"color: #a020f0;\">new</span> <span style=\"color: #228b22;\">Array</span>(5) =&gt; Array(5)\n<span style=\"color: #a020f0;\">new</span> <span style=\"color: #228b22;\">Array</span>(a) =&gt; Array(a)\n</pre>\n\n\n\n<p>\nThese are all safe if the Array name isn't redefined. JavaScript does allow\none to globally redefine Array (and pretty much everything, in fact) but I\npersonally don't see why would anyone do that.\n</p>\n<p>\nUglifyJS does handle the case where Array is redefined locally, or even\nglobally but with a <code>function</code> or <code>var</code> declaration. Therefore, in the\nfollowing cases UglifyJS <b>doesn't touch</b> calls or instantiations of Array:\n</p>\n\n\n\n<pre class=\"src src-js\"><span style=\"color: #b22222;\">// </span><span style=\"color: #b22222;\">case 1. globally declared variable\n</span> <span style=\"color: #a020f0;\">var</span> <span style=\"color: #b8860b;\">Array</span>;\n <span style=\"color: #a020f0;\">new</span> <span style=\"color: #228b22;\">Array</span>(1, 2, 3);\n Array(a, b);\n\n <span style=\"color: #b22222;\">// </span><span style=\"color: #b22222;\">or (can be declared later)\n</span> <span style=\"color: #a020f0;\">new</span> <span style=\"color: #228b22;\">Array</span>(1, 2, 3);\n <span style=\"color: #a020f0;\">var</span> <span style=\"color: #b8860b;\">Array</span>;\n\n <span style=\"color: #b22222;\">// </span><span style=\"color: #b22222;\">or (can be a function)\n</span> <span style=\"color: #a020f0;\">new</span> <span style=\"color: #228b22;\">Array</span>(1, 2, 3);\n <span style=\"color: #a020f0;\">function</span> <span style=\"color: #0000ff;\">Array</span>() { ... }\n\n<span style=\"color: #b22222;\">// </span><span style=\"color: #b22222;\">case 2. declared in a function\n</span> (<span style=\"color: #a020f0;\">function</span>(){\n a = <span style=\"color: #a020f0;\">new</span> <span style=\"color: #228b22;\">Array</span>(1, 2, 3);\n b = Array(5, 6);\n <span style=\"color: #a020f0;\">var</span> <span style=\"color: #b8860b;\">Array</span>;\n })();\n\n <span style=\"color: #b22222;\">// </span><span style=\"color: #b22222;\">or\n</span> (<span style=\"color: #a020f0;\">function</span>(<span style=\"color: #b8860b;\">Array</span>){\n <span style=\"color: #a020f0;\">return</span> Array(5, 6, 7);\n })();\n\n <span style=\"color: #b22222;\">// </span><span style=\"color: #b22222;\">or\n</span> (<span style=\"color: #a020f0;\">function</span>(){\n <span style=\"color: #a020f0;\">return</span> <span style=\"color: #a020f0;\">new</span> <span style=\"color: #228b22;\">Array</span>(1, 2, 3, 4);\n <span style=\"color: #a020f0;\">function</span> <span style=\"color: #0000ff;\">Array</span>() { ... }\n })();\n\n <span style=\"color: #b22222;\">// </span><span style=\"color: #b22222;\">etc.\n</span></pre>\n\n\n\n</div>\n</div>\n\n</div>\n\n<div id=\"outline-container-1_2\" class=\"outline-3\">\n<h3 id=\"sec-1_2\"><span class=\"section-number-3\">1.2</span> Install (NPM) </h3>\n<div class=\"outline-text-3\" id=\"text-1_2\">\n\n\n<p>\nUglifyJS is now available through NPM &mdash; <code>npm install uglify-js</code> should do\nthe job.\n</p>\n</div>\n\n</div>\n\n<div id=\"outline-container-1_3\" class=\"outline-3\">\n<h3 id=\"sec-1_3\"><span class=\"section-number-3\">1.3</span> Install latest code from GitHub </h3>\n<div class=\"outline-text-3\" id=\"text-1_3\">\n\n\n\n\n\n<pre class=\"src src-sh\"><span style=\"color: #b22222;\">## </span><span style=\"color: #b22222;\">clone the repository\n</span>mkdir -p /where/you/wanna/put/it\n<span style=\"color: #da70d6;\">cd</span> /where/you/wanna/put/it\ngit clone git://github.com/mishoo/UglifyJS.git\n\n<span style=\"color: #b22222;\">## </span><span style=\"color: #b22222;\">make the module available to Node\n</span>mkdir -p ~/.node_libraries/\n<span style=\"color: #da70d6;\">cd</span> ~/.node_libraries/\nln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js\n\n<span style=\"color: #b22222;\">## </span><span style=\"color: #b22222;\">and if you want the CLI script too:\n</span>mkdir -p ~/bin\n<span style=\"color: #da70d6;\">cd</span> ~/bin\nln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs\n <span style=\"color: #b22222;\"># </span><span style=\"color: #b22222;\">(then add ~/bin to your $PATH if it's not there already)\n</span></pre>\n\n\n\n</div>\n\n</div>\n\n<div id=\"outline-container-1_4\" class=\"outline-3\">\n<h3 id=\"sec-1_4\"><span class=\"section-number-3\">1.4</span> Usage </h3>\n<div class=\"outline-text-3\" id=\"text-1_4\">\n\n\n<p>\nThere is a command-line tool that exposes the functionality of this library\nfor your shell-scripting needs:\n</p>\n\n\n\n<pre class=\"src src-sh\">uglifyjs [ options... ] [ filename ]\n</pre>\n\n\n\n<p>\n<code>filename</code> should be the last argument and should name the file from which\nto read the JavaScript code. If you don't specify it, it will read code\nfrom STDIN.\n</p>\n<p>\nSupported options:\n</p>\n<ul>\n<li>\n<code>-b</code> or <code>--beautify</code> &mdash; output indented code; when passed, additional\noptions control the beautifier:\n\n<ul>\n<li>\n<code>-i N</code> or <code>--indent N</code> &mdash; indentation level (number of spaces)\n\n</li>\n<li>\n<code>-q</code> or <code>--quote-keys</code> &mdash; quote keys in literal objects (by default,\nonly keys that cannot be identifier names will be quotes).\n\n</li>\n</ul>\n</li>\n<li>\n<code>--ascii</code> &mdash; pass this argument to encode non-ASCII characters as\n<code>\\uXXXX</code> sequences. By default UglifyJS won't bother to do it and will\noutput Unicode characters instead. (the output is always encoded in UTF8,\nbut if you pass this option you'll only get ASCII).\n\n</li>\n<li>\n<code>-nm</code> or <code>--no-mangle</code> &mdash; don't mangle variable names\n\n</li>\n<li>\n<code>-ns</code> or <code>--no-squeeze</code> &mdash; don't call <code>ast_squeeze()</code> (which does various\noptimizations that result in smaller, less readable code).\n\n</li>\n<li>\n<code>-mt</code> or <code>--mangle-toplevel</code> &mdash; mangle names in the toplevel scope too\n(by default we don't do this).\n\n</li>\n<li>\n<code>--no-seqs</code> &mdash; when <code>ast_squeeze()</code> is called (thus, unless you pass\n<code>--no-squeeze</code>) it will reduce consecutive statements in blocks into a\nsequence. For example, \"a = 10; b = 20; foo();\" will be written as\n\"a=10,b=20,foo();\". In various occasions, this allows us to discard the\nblock brackets (since the block becomes a single statement). This is ON\nby default because it seems safe and saves a few hundred bytes on some\nlibs that I tested it on, but pass <code>--no-seqs</code> to disable it.\n\n</li>\n<li>\n<code>--no-dead-code</code> &mdash; by default, UglifyJS will remove code that is\nobviously unreachable (code that follows a <code>return</code>, <code>throw</code>, <code>break</code> or\n<code>continue</code> statement and is not a function/variable declaration). Pass\nthis option to disable this optimization.\n\n</li>\n<li>\n<code>-nc</code> or <code>--no-copyright</code> &mdash; by default, <code>uglifyjs</code> will keep the initial\ncomment tokens in the generated code (assumed to be copyright information\netc.). If you pass this it will discard it.\n\n</li>\n<li>\n<code>-o filename</code> or <code>--output filename</code> &mdash; put the result in <code>filename</code>. If\nthis isn't given, the result goes to standard output (or see next one).\n\n</li>\n<li>\n<code>--overwrite</code> &mdash; if the code is read from a file (not from STDIN) and you\npass <code>--overwrite</code> then the output will be written in the same file.\n\n</li>\n<li>\n<code>--ast</code> &mdash; pass this if you want to get the Abstract Syntax Tree instead\nof JavaScript as output. Useful for debugging or learning more about the\ninternals.\n\n</li>\n<li>\n<code>-v</code> or <code>--verbose</code> &mdash; output some notes on STDERR (for now just how long\neach operation takes).\n\n</li>\n<li>\n<code>--extra</code> &mdash; enable additional optimizations that have not yet been\nextensively tested. These might, or might not, break your code. If you\nfind a bug using this option, please report a test case.\n\n</li>\n<li>\n<code>--unsafe</code> &mdash; enable other additional optimizations that are known to be\nunsafe in some contrived situations, but could still be generally useful.\nFor now only this:\n\n<ul>\n<li>\nfoo.toString() ==&gt; foo+\"\"\n\n</li>\n</ul>\n</li>\n<li>\n<code>--max-line-len</code> (default 32K characters) &mdash; add a newline after around\n32K characters. I've seen both FF and Chrome croak when all the code was\non a single line of around 670K. Pass &ndash;max-line-len 0 to disable this\nsafety feature.\n\n</li>\n<li>\n<code>--reserved-names</code> &mdash; some libraries rely on certain names to be used, as\npointed out in issue #92 and #81, so this option allow you to exclude such\nnames from the mangler. For example, to keep names <code>require</code> and <code>$super</code>\nintact you'd specify &ndash;reserved-names \"require,$super\".\n</li>\n</ul>\n\n\n\n</div>\n\n<div id=\"outline-container-1_4_1\" class=\"outline-4\">\n<h4 id=\"sec-1_4_1\"><span class=\"section-number-4\">1.4.1</span> API </h4>\n<div class=\"outline-text-4\" id=\"text-1_4_1\">\n\n\n<p>\nTo use the library from JavaScript, you'd do the following (example for\nNodeJS):\n</p>\n\n\n\n<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;\n<span style=\"color: #a020f0;\">var</span> <span style=\"color: #b8860b;\">pro</span> = require(<span style=\"color: #bc8f8f;\">\"uglify-js\"</span>).uglify;\n\n<span style=\"color: #a020f0;\">var</span> <span style=\"color: #b8860b;\">orig_code</span> = <span style=\"color: #bc8f8f;\">\"... JS code here\"</span>;\n<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\n</span>ast = pro.ast_mangle(ast); <span style=\"color: #b22222;\">// </span><span style=\"color: #b22222;\">get a new AST with mangled names\n</span>ast = pro.ast_squeeze(ast); <span style=\"color: #b22222;\">// </span><span style=\"color: #b22222;\">get an AST with compression optimizations\n</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\n</span></pre>\n\n\n\n<p>\nThe above performs the full compression that is possible right now. As you\ncan see, there are a sequence of steps which you can apply. For example if\nyou want compressed output but for some reason you don't want to mangle\nvariable names, you would simply skip the line that calls\n<code>pro.ast_mangle(ast)</code>.\n</p>\n<p>\nSome of these functions take optional arguments. Here's a description:\n</p>\n<ul>\n<li>\n<code>jsp.parse(code, strict_semicolons)</code> &ndash; parses JS code and returns an AST.\n<code>strict_semicolons</code> is optional and defaults to <code>false</code>. If you pass\n<code>true</code> then the parser will throw an error when it expects a semicolon and\nit doesn't find it. For most JS code you don't want that, but it's useful\nif you want to strictly sanitize your code.\n\n</li>\n<li>\n<code>pro.ast_mangle(ast, options)</code> &ndash; generates a new AST containing mangled\n(compressed) variable and function names. It supports the following\noptions:\n\n<ul>\n<li>\n<code>toplevel</code> &ndash; mangle toplevel names (by default we don't touch them).\n</li>\n<li>\n<code>except</code> &ndash; an array of names to exclude from compression.\n\n</li>\n</ul>\n</li>\n<li>\n<code>pro.ast_squeeze(ast, options)</code> &ndash; employs further optimizations designed\nto reduce the size of the code that <code>gen_code</code> would generate from the\nAST. Returns a new AST. <code>options</code> can be a hash; the supported options\nare:\n\n<ul>\n<li>\n<code>make_seqs</code> (default true) which will cause consecutive statements in a\nblock to be merged using the \"sequence\" (comma) operator\n\n</li>\n<li>\n<code>dead_code</code> (default true) which will remove unreachable code.\n\n</li>\n</ul>\n</li>\n<li>\n<code>pro.gen_code(ast, options)</code> &ndash; generates JS code from the AST. By\ndefault it's minified, but using the <code>options</code> argument you can get nicely\nformatted output. <code>options</code> is, well, optional :-) and if you pass it it\nmust be an object and supports the following properties (below you can see\nthe default values):\n\n<ul>\n<li>\n<code>beautify: false</code> &ndash; pass <code>true</code> if you want indented output\n</li>\n<li>\n<code>indent_start: 0</code> (only applies when <code>beautify</code> is <code>true</code>) &ndash; initial\nindentation in spaces\n</li>\n<li>\n<code>indent_level: 4</code> (only applies when <code>beautify</code> is <code>true</code>) --\nindentation level, in spaces (pass an even number)\n</li>\n<li>\n<code>quote_keys: false</code> &ndash; if you pass <code>true</code> it will quote all keys in\nliteral objects\n</li>\n<li>\n<code>space_colon: false</code> (only applies when <code>beautify</code> is <code>true</code>) &ndash; wether\nto put a space before the colon in object literals\n</li>\n<li>\n<code>ascii_only: false</code> &ndash; pass <code>true</code> if you want to encode non-ASCII\ncharacters as <code>\\uXXXX</code>.\n</li>\n</ul>\n</li>\n</ul>\n\n\n</div>\n\n</div>\n\n<div id=\"outline-container-1_4_2\" class=\"outline-4\">\n<h4 id=\"sec-1_4_2\"><span class=\"section-number-4\">1.4.2</span> Beautifier shortcoming &ndash; no more comments </h4>\n<div class=\"outline-text-4\" id=\"text-1_4_2\">\n\n\n<p>\nThe beautifier can be used as a general purpose indentation tool. It's\nuseful when you want to make a minified file readable. One limitation,\nthough, is that it discards all comments, so you don't really want to use it\nto reformat your code, unless you don't have, or don't care about, comments.\n</p>\n<p>\nIn fact it's not the beautifier who discards comments &mdash; they are dumped at\nthe parsing stage, when we build the initial AST. Comments don't really\nmake sense in the AST, and while we could add nodes for them, it would be\ninconvenient because we'd have to add special rules to ignore them at all\nthe processing stages.\n</p>\n</div>\n</div>\n\n</div>\n\n<div id=\"outline-container-1_5\" class=\"outline-3\">\n<h3 id=\"sec-1_5\"><span class=\"section-number-3\">1.5</span> Compression &ndash; how good is it? </h3>\n<div class=\"outline-text-3\" id=\"text-1_5\">\n\n\n<p>\n(XXX: this is somewhat outdated. On the jQuery source code we beat Closure\nby 168 bytes (560 after gzip) and by many seconds.)\n</p>\n<p>\nThere are a few popular JS minifiers nowadays &ndash; the two most well known\nbeing the GoogleClosure (GCL) compiler and the YUI compressor. For some\nreason they are both written in Java. I didn't really hope to beat any of\nthem, but finally I did &ndash; UglifyJS compresses better than the YUI\ncompressor, and safer than GoogleClosure.\n</p>\n<p>\nI tested it on two big libraries. <a href=\"http://www.dynarchlib.com/\">DynarchLIB</a> is my own, and it's big enough\nto contain probably all the JavaScript tricks known to mankind. <a href=\"http://jquery.com/\">jQuery</a> is\ndefinitely the most popular JavaScript library (to some people, it's a\nsynonym to JavaScript itself).\n</p>\n<p>\nI cannot swear that there are no bugs in the generated codes, but they\nappear to work fine.\n</p>\n<p>\nCompression results:\n</p>\n<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">\n<caption></caption>\n<colgroup><col align=\"left\" /><col align=\"right\" /><col align=\"right\" /><col align=\"left\" /><col align=\"left\" />\n</colgroup>\n<thead>\n<tr><th scope=\"col\">Library</th><th scope=\"col\">Orig. size</th><th scope=\"col\">UglifyJS</th><th scope=\"col\">YUI</th><th scope=\"col\">GCL</th></tr>\n</thead>\n<tbody>\n<tr><td>DynarchLIB</td><td>636896</td><td>241441</td><td>246452 (+5011)</td><td>240439 (-1002) (buggy)</td></tr>\n<tr><td>jQuery</td><td>163855</td><td>72006</td><td>79702 (+7696)</td><td>71858 (-148)</td></tr>\n</tbody>\n</table>\n\n\n<p>\nUglifyJS is the fastest to run. On my laptop UglifyJS takes 1.35s for\nDynarchLIB, while YUI takes 2.7s and GCL takes 6.5s.\n</p>\n<p>\nGoogleClosure does a lot of smart ass optimizations. I had to strive really\nhard to get close to it. It should be possible to even beat it, but then\nagain, GCL has a gazillion lines of code and runs terribly slow, so I'm not\nsure it worths spending the effort to save a few bytes. Also, GCL doesn't\ncope with <code>eval()</code> or <code>with{}</code> &ndash; it just dumps a warning and proceeds to\nmangle names anyway; my DynarchLIB compiled with it is buggy because of\nthis.\n</p>\n<p>\nUglifyJS consists of ~1100 lines of code for the tokenizer/parser, and ~1100\nlines for the compressor and code generator. That should make it very\nmaintainable and easily extensible, so I would say it has a good place in\nthis field and it's bound to become the de-facto standard JS minifier. And\nI shall rule the world. :-) Use it, and <b>spread the word</b>!\n</p>\n</div>\n\n</div>\n\n<div id=\"outline-container-1_6\" class=\"outline-3\">\n<h3 id=\"sec-1_6\"><span class=\"section-number-3\">1.6</span> Bugs? </h3>\n<div class=\"outline-text-3\" id=\"text-1_6\">\n\n\n<p>\nUnfortunately, for the time being there is no automated test suite. But I\nran the compressor manually on non-trivial code, and then I tested that the\ngenerated code works as expected. A few hundred times.\n</p>\n<p>\nDynarchLIB was started in times when there was no good JS minifier.\nTherefore I was quite religious about trying to write short code manually,\nand as such DL contains a lot of syntactic hacks<sup><a class=\"footref\" name=\"fnr.1\" href=\"#fn.1\">1</a></sup> such as “foo == bar ? a\n= 10 : b = 20”, though the more readable version would clearly be to use\n“if/else”.\n</p>\n<p>\nSince the parser/compressor runs fine on DL and jQuery, I'm quite confident\nthat it's solid enough for production use. If you can identify any bugs,\nI'd love to hear about them (<a href=\"http://groups.google.com/group/uglifyjs\">use the Google Group</a> or email me directly).\n</p>\n</div>\n\n</div>\n\n<div id=\"outline-container-1_7\" class=\"outline-3\">\n<h3 id=\"sec-1_7\"><span class=\"section-number-3\">1.7</span> Links </h3>\n<div class=\"outline-text-3\" id=\"text-1_7\">\n\n\n<ul>\n<li>\nProject at GitHub: <a href=\"http://github.com/mishoo/UglifyJS\">http://github.com/mishoo/UglifyJS</a>\n</li>\n<li>\nGoogle Group: <a href=\"http://groups.google.com/group/uglifyjs\">http://groups.google.com/group/uglifyjs</a>\n</li>\n<li>\nCommon Lisp JS parser: <a href=\"http://marijn.haverbeke.nl/parse-js/\">http://marijn.haverbeke.nl/parse-js/</a>\n</li>\n<li>\nJS-to-Lisp compiler: <a href=\"http://github.com/marijnh/js\">http://github.com/marijnh/js</a>\n</li>\n<li>\nCommon Lisp JS uglifier: <a href=\"http://github.com/mishoo/cl-uglify-js\">http://github.com/mishoo/cl-uglify-js</a>\n</li>\n</ul>\n\n\n</div>\n\n</div>\n\n<div id=\"outline-container-1_8\" class=\"outline-3\">\n<h3 id=\"sec-1_8\"><span class=\"section-number-3\">1.8</span> License </h3>\n<div class=\"outline-text-3\" id=\"text-1_8\">\n\n\n<p>\nUglifyJS is released under the BSD license:\n</p>\n\n\n\n<pre class=\"example\">Copyright 2010 (c) Mihai Bazon &lt;mihai.bazon@gmail.com&gt;\nBased on parse-js (http://marijn.haverbeke.nl/parse-js/).\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n * Redistributions of source code must retain the above\n copyright notice, this list of conditions and the following\n disclaimer.\n\n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials\n provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY\nEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\nOR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR\nTORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF\nTHE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGE.\n</pre>\n\n\n\n\n</div>\n</div>\n</div>\n<div id=\"footnotes\">\n<h2 class=\"footnotes\">Footnotes: </h2>\n<div id=\"text-footnotes\">\n<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\n<a href=\"http://marijn.haverbeke.nl/parse-js/\">parse-js</a> library, and Marijn pushed fixes literally in minutes.\n</p>\n</div>\n</div>\n<div id=\"postamble\">\n<p class=\"author\"> Author: Mihai Bazon\n</p>\n<p class=\"date\"> Date: 2011-04-04 00:07:13 EEST</p>\n<p class=\"creator\">HTML generated by org-mode 7.01trans in emacs 23</p>\n</div>\n</div>\n</body>\n</html>\n",
  18. "_id": "uglify-js@1.0.3",
  19. "description": "<?xml version=\"1.0\" encoding=\"utf-8\"?> <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\"> <head> <title>UglifyJS -- 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-04-04 00:07:13 EEST\"/> <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\"/> <style type=\"text/css\"> <!--/*--><![CDATA[/*><!--*/ html { font-family: Times, serif; font-size: 12pt; } .title { text-align: center; } .todo { color: red; } .done { color: green; } .tag { background-color: #add8e6; font-weight:normal } .target { } .timestamp { color: #bebebe; } .timestamp-kwd { color: #5f9ea0; } p.verse { margin-left: 3% } pre { \tborder: 1pt solid #AEBDCC; \tbackground-color: #F3F5F7; \tpadding: 5pt; \tfont-family: courier, monospace; font-size: 90%; overflow:auto; } table { border-collapse: collapse; } td, th { vertical-align: top; } dt { font-weight: bold; } div.figure { padding: 0.5em; } div.figure p { text-align: center; } textarea { overflow-x: auto; } .linenr { font-size:smaller } .code-highlighted {background-color:#ffff00;} .org-info-js_info-navigation { border-style:none; } #org-info-js_console-label { font-size:10px; font-weight:bold; white-space:nowrap; } .org-info-js_search-highlight {background-color:#ffff00; color:#000000; font-weight:bold; } /*]]>*/--> </style> <link rel=\"stylesheet\" type=\"text/css\" href=\"docstyle.css\" /> <script type=\"text/javascript\"> <!--/*--><![CDATA[/*><!--*/ function CodeHighlightOn(elem, id) { var target = document.getElementById(id); if(null != target) { elem.cacheClassElem = elem.className; elem.cacheClassTarget = target.className; target.className = \"code-highlighted\"; elem.className = \"code-highlighted\"; } } function CodeHighlightOff(elem, id) { var target = document.getElementById(id); if(elem.cacheClassElem) elem.className = elem.cacheClassElem; if(elem.cacheClassTarget) target.className = elem.cacheClassTarget; } /*]]>*///--> </script>",
  20. "dist": {
  21. "shasum": "930ac58cf8923ba3d4062f3877d3484887cd8193"
  22. },
  23. "_from": "uglify-js@1.0.3"
  24. }