Successfully reported this slideshow.
Upcoming SlideShare
×

# Closure Compiler vs YUICompressor

51,005 views

Published on

Published in: Technology, News & Politics
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Thanks for this test! http://groupb.ru/

Are you sure you want to  Yes  No
• Hello.

Are you sure you want to  Yes  No
• Hello.Thanks for this test! http://groupb.ru/

Are you sure you want to  Yes  No
• Any video/audio resource for this presentation? That would be helpful!

Are you sure you want to  Yes  No
• suuuper, Thanks More hotwebcam girls in live without registration on http://BestCamX.com

Are you sure you want to  Yes  No

### Closure Compiler vs YUICompressor

1. 1. Google Closure Compiler vs. YUI Compressor lifesinger@gmail.com 2009-11-09
2. 2. Who’s this guy? http://lifesinger.org/
5. 5. Optimization Levels ① Whitespace Level ② Simple Optimizations ③ Advanced Optimizations
6. 6. Whitespace
7. 7. Whitespace Level • Remove comments • Remove extra white space • Remove unneccessary semicolon GC YC
8. 8. Simple Optimizations
9. 9. Simple Optimizations • var varName = “”  var a = “” • object[“property”]  object.property • {“key” : “val”}  {key : “val”} • „xi‟an‟  “xi‟an” • “I am ” + “hot”  “I am hot” GC YC
10. 10. Simple Optimizations • a = new Object  a = {} • a = new Array  a = [] • if(a) b()  a && b() • if(a) b(); else c()  a ? b() : c() • if(1) b(); else c()  b() • return 2 * 3;  return 6; • return undefined;  return; • var f = function(){}  function f(){} • var a; var b;  var a, b; • … GC YC
11. 11. Simple Optimizations • Simple dead code removal GC YC
13. 13. Advanced Optimizations • Dead code removal & Function inlining GC YC
14. 14. Advanced Optimizations • Aggressive renaming GC unsafe
16. 16. Whitespace Level Simple Level Advanced Level GC YC Basic
17. 17. Helping Compressors
18. 18. Helping Compressors ① Use local variables to store: 1. Repeated primitive values 2. Global variables 3. Object properties Good practices for YC and GC both.
19. 19. Helping Compressors ② Try to have only one var statement: Good practice for YC. Unneccessary for GC.
20. 20. Hurting Compressors
21. 21. Hurting Compressors ① eval() is Evil. GC YC
22. 22. Hurting Compressors ② with statement considered harmful. GC YC
23. 23. Hurting Compressors ③ Jscript conditional comments
24. 24. Hurting Compressors  Solutions: - Solution #1: Don’t use - Solution #2: See Solution #1
25. 25. Sugar