Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged pull request #133 from aaronblohowiak/master.

Convenience function for minification
  • Loading branch information...
commit 8f4fe4c555f0b4fd7108739ec5edcdfb0c5b74fe 2 parents b5d994a + f0e1ec2
@mishoo mishoo authored
Showing with 17 additions and 2 deletions.
  1. +17 −2 uglify-js.js
View
19 uglify-js.js
@@ -1,2 +1,17 @@
-exports.parser = require("./lib/parse-js");
-exports.uglify = require("./lib/process");
+//convienence function(src, [options]);
+function uglify(orig_code, options){
+ options || (options = {});
+ var jsp = uglify.parser;
+ var pro = uglify.uglify;
+
+ var ast = jsp.parse(orig_code, options.strict_semicolons); // parse code and get the initial AST
+ ast = pro.ast_mangle(ast, options.mangle_options); // get a new AST with mangled names
+ ast = pro.ast_squeeze(ast, options.squeeze_options); // get an AST with compression optimizations
+ var final_code = pro.gen_code(ast, options.gen_options); // compressed code here
+ return final_code;
+};
+
+uglify.parser = require("./lib/parse-js");
+uglify.uglify = require("./lib/process");
+
+module.exports = uglify
Please sign in to comment.
Something went wrong with that request. Please try again.