[ 2 posts ]

Sucky Fish

  • Username: suckfish
  • Joined: Thu Sep 01, 2011 4:02 pm
  • Posts: 1
  • Offline
  • Profile

yui-compressor pessimisation

Post Posted: Thu Sep 01, 2011 4:35 pm
+0-
Hi,

Thanks for Yui-compressor!

Some observations:

Yui-compressor can expand code size by inserting unnecessary braces:

function x(y){if(y)return 1;return 0}

becomes:

function x(a){if(a){return 1}return 0};

(also not sure why the trailing ';' gets added).

Other optimisations that I think might not be too difficult to implement:

Combine multiple var statements: "var a;var b;" could become just "var a,b;". This can also be worthwhile for non-consecutive var statements with initialisers:

var a=1;f(a);var b=g(2);h(b);

becomes

var a=1,b;f(a);b=g(2);h(b);

saving 2-characters.

Converting ';' to ',' can sometimes save the need for braces, saving a character or two:
if(a){f();g()} becomes if(a)f(),g();

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: yui-compressor pessimisation

Post Posted: Fri Sep 02, 2011 9:44 pm
+0-
Please file a new ticket:

http://yuilibrary.com/projects/yuicompressor/newticket

Conversations on the forum are not tracked so they are eventually forgotten.
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum