Esmangle: mangling tool for Mozilla Parser AST

110 views
Skip to first unread message

Yusuke Suzuki

unread,
Aug 31, 2012, 12:42:20 PM8/31/12
to esp...@googlegroups.com
Hello all,

Last night, I decided to implement some AST modifying pass, and created esmangle : mangling tool for Mozilla Parser AST.

This is created yesterday and test cases are very few, so it is still experimental. :)

We can use it like this,

var first = esprima.parse(code);
var tree =esmangle.mangle(first);
var res = escodegen.generate(first, { format: { compact: true, semicolons: false, renumber: true, hexadecimal: true, escapeless: true } });

You can try this on the demo page.

To get more compression ratio, we should create AST modifying pass like

+ remove wasted block. (`if (cond) { stmt; }` => `if (cond) stmt;)
+ reordering declarations
+ concat multiple var declarations into one

Thanks.

Ariya Hidayat

unread,
Aug 31, 2012, 11:42:29 PM8/31/12
to esp...@googlegroups.com

Quite impressive!

I'd assume you would look into comparing the result with UglifyJS, or even its new UglifyJS 2.

As for non-mangling syntax simplification, should this be another (micro)library? It could be still useful for pure optimization purposes, even without further mangling step.

--
Ariya

Yusuke Suzuki

unread,
Sep 2, 2012, 10:48:48 AM9/2/12
to esp...@googlegroups.com
Thanks!

I'd assume you would look into comparing the result with UglifyJS, or even its new UglifyJS 2.

I'm planning to compare results with them and refactor (or implement better compressing optimization fix) esmangle and escodegen.

As for non-mangling syntax simplification, should this be another (micro)library? It could be still useful for pure optimization purposes, even without further mangling step.

Sounds good. So I'll implement them as another `pass` module, thanks for your advice :)

Regards,
Yusuke Suzuki
Reply all
Reply to author
Forward
0 new messages