Javascript Optimizations

I was looking at kangax‘s suggestions for Google Closure compression techniques and I wanted to know how UglifyJS handled it.

var i = 10000,
j = 0.1,
k = /[\w]/,
m = new Array(1, 2, 3);
throw 0.1;

var i=1E4,j=0.1,k=/[\w]/,m=[1,2,3];throw 0.1;

var i=1e4,j=.1,k=/[\w]/,m=new Array(1,2,3);throw.1

Interesting that UglifyJS doesn’t compress the Array declaration, but does compress 2 other statements that Google Closure doesn’t/won’t.

In UglifyJS’s README it states that Google Closure “runs terribly slow”. Why is this an issue? Won’t you only compress when pushing to prod?

3 thoughts on “Javascript Optimizations

  1. Ah, good catch on new Array()! I’ll push a fix for this soon.

    It’s not that I’m minifying JavaScript on the fly, but I’m rather impatient. Why wait 6 seconds when I can only wait one? 😉

Leave a Reply

Your email address will not be published. Required fields are marked *