diff --git a/.gitignore b/.gitignore
index d97eaa09..da080d93 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
.DS_Store
.tmp*~
*.local.*
-.pinf-*
\ No newline at end of file
+.pinf-*
+/dist
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..ee8561b5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,28 @@
+Copyright (c) 2011 Mihai Bazon
-Symlink the lib directory as ~/.node_libraries/uglifyjs, so that the
-require calls in the following sample will work:
+Symlink the Table of Contents
1.1.1 Calls involving t
-
new Array(1, 2, 3, 4) => [1,2,3,4]
+
new Array(1, 2, 3, 4) => [1,2,3,4]
Array(a, b, c) => [a,b,c]
-new Array(5) => Array(5)
-new Array(a) => Array(a)
+new Array(5) => Array(5)
+new Array(a) => Array(a)
@@ -271,38 +281,38 @@ 1.1.1 Calls involving t
-
// case 1. globally declared variable
- var Array;
- new Array(1, 2, 3);
+
// case 1. globally declared variable
+ var Array;
+ new Array(1, 2, 3);
Array(a, b);
- // or (can be declared later)
- new Array(1, 2, 3);
- var Array;
+ // or (can be declared later)
+ new Array(1, 2, 3);
+ var Array;
- // or (can be a function)
- new Array(1, 2, 3);
- function Array() { ... }
+ // or (can be a function)
+ new Array(1, 2, 3);
+ function Array() { ... }
-// case 2. declared in a function
- (function(){
- a = new Array(1, 2, 3);
+// case 2. declared in a function
+ (function(){
+ a = new Array(1, 2, 3);
b = Array(5, 6);
- var Array;
+ var Array;
})();
- // or
- (function(Array){
- return Array(5, 6, 7);
+ // or
+ (function(Array){
+ return Array(5, 6, 7);
})();
- // or
- (function(){
- return new Array(1, 2, 3, 4);
- function Array() { ... }
+ // or
+ (function(){
+ return new Array(1, 2, 3, 4);
+ function Array() { ... }
})();
- // etc.
+ // etc.
@@ -455,20 +465,20 @@ 1.2.1 API
lib
directory as ~/.node_libraries/uglify-js
(or run
+npm link
) so that the require calls in the following sample will work:
var jsp = require("uglifyjs/parse-js");
-var pro = require("uglifyjs/process");
+
var UglifyJS = require("uglify-js");
+var parser = UglifyJS.parser, uglify = UglifyJS.uglify;
-var orig_code = "... JS code here";
-var ast = jsp.parse(orig_code); // parse code and get the initial AST
-ast = pro.ast_mangle(ast); // get a new AST with mangled names
-ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
-var final_code = pro.gen_code(ast); // compressed code here
+var orig_code = "... JS code here";
+var ast = parser.parse(orig_code); // parse code and get the initial AST
+ast = uglify.ast_mangle(ast); // get a new AST with mangled names
+ast = uglify.ast_squeeze(ast); // get an AST with compression optimizations
+var final_code = uglify.gen_code(ast); // compressed code here
@@ -478,14 +488,14 @@ 1.2.1 API
can see, there are a sequence of steps which you can apply. For example if
you want compressed output but for some reason you don't want to mangle
variable names, you would simply skip the line that calls
-pro.ast_mangle(ast)
.
+uglify.ast_mangle(ast)
.
Some of these functions take optional arguments. Here's a description:
jsp.parse(code, strict_semicolons)
– parses JS code and returns an AST.
+parser.parse(code, strict_semicolons)
– parses JS code and returns an AST.
strict_semicolons
is optional and defaults to false
. If you pass
true
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
@@ -493,7 +503,7 @@ pro.ast_mangle(ast, options)
– generates a new AST containing mangled
+uglify.ast_mangle(ast, options)
– generates a new AST containing mangled
(compressed) variable and function names. It supports the following
options:
@@ -508,7 +518,7 @@ pro.ast_squeeze(ast, options)
– employs further optimizations designed
+uglify.ast_squeeze(ast, options)
– employs further optimizations designed
to reduce the size of the code that gen_code
would generate from the
AST. Returns a new AST. options
can be a hash; the supported options
are:
@@ -526,7 +536,7 @@ pro.gen_code(ast, beautify)
– generates JS code from the AST. By
+uglify.gen_code(ast, beautify)
– generates JS code from the AST. By
default it's minified, but if you pass true
for the second argument it
will be nicely formatted and indented. Additionally, you can control the
behavior by passing a hash for beautify
, where the following options are
@@ -553,10 +563,27 @@
+If you have the Stitch library installed (npm install stitch
) you
+can build a version of UglifyJS for use in the browser or any other
+non-CommonJS environment. Run make dist
to generate a distributable
+script at dist/uglify.js
. When loaded, the distributable version
+adds an UglifyJS
property to the global object without the need to
+call require. Otherwise, the API is the same as described above.
+
The beautifier can be used as a general purpose indentation tool. It's useful when you want to make a minified file readable. One limitation, @@ -606,14 +633,14 @@
Library | Orig. size | UglifyJS | YUI | GCL |
---|---|---|---|---|
Library | Orig. size | UglifyJS | YUI | GCL |
DynarchLIB | 636896 | 241441 | 246452 (+5011) | 240439 (-1002) (buggy) |
jQuery | 163855 | 72006 | 79702 (+7696) | 71858 (-148) |
DynarchLIB | 636896 | 241441 | 246452 (+5011) | 240439 (-1002) (buggy) |
jQuery | 163855 | 72006 | 79702 (+7696) | 71858 (-148) |
Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com> +Copyright (c) 2011 Mihai Bazon <mihai.bazon@gmail.com> Based on parse-js (http://marijn.haverbeke.nl/parse-js/). Redistribution and use in source and binary forms, with or without @@ -754,8 +781,8 @@Footnotes:
-Date: 2011-02-19 11:12:48 EET
-HTML generated by org-mode 7.01trans in emacs 23
+Date: 2011-02-20 15:40:21 CST
+HTML generated by org-mode 7.4 in emacs 24