Closure Compiler is a JavaScript optimizing compiler.

來源:互聯網
上載者:User

http://code.google.com/p/closure-compiler/

 http://stackoverflow.com/questions/28932/best-javascript-compressor

Google released Closure Compiler which seems to be generating the smallest files so far as seen hereand here

Previous to that the various options were as follow

Basically Packer does a better job at initial compression , but if you are going to gzip the files before sending on the wire (which you should be doing) YUI Compressor gets the smallest final size.

The tests were done on jQuery code btw.

  • Original jQuery library 62,885 bytes , 19,758 bytes after gzip
  • jQuery minified with JSMin 36,391 bytes , 11,541 bytes after gzip
  • jQuery minified with Packer 21,557 bytes , 11,119 bytes after gzip
  • jQuery minified with the YUI Compressor 31,822 bytes , 10,818 bytes after gzip

@daniel james mentions in the comment compressorrater which shows Packer leading the chart in best compression, so I guess ymmv

link|improve this answer edited Nov 8 '09 at 10:00   answered Aug 26 '08 at 19:48Pat
12.4k63365
 
  Packer has an option to 'base62 encode' off - and for jQuery it compresses smaller than yui after gzip. This is because jquery uses 'eval' and 'with' which prevents 'safe' compressors from doing certain compressions, but packer ignores them. Not safe in general but jQuery is tested for Packer. – Daniel James Sep 17 '08 at 7:19
  Also, try compressorrater.thruhere.net if you don't believe me. – Daniel James Sep 17 '08 at 7:22
6  
Don't forget the downside to packer--decompression time. – Nosredna Jun 7 '09 at 15:57
1  
Wow, this tool is pretty awesome. *&^@#$!! Google, they provide so many things that it kind of makes me wary to use them, since they do nearly everything these days. They are taking over the world... – Jason Bunting Aug 24 '10 at 16:33
  watch out, google closure can sometimes be the worst compressor (output even larger than original) - it converts non-ascii characters in strings to \uxxxx literals by default.. use e.g. --charset UTF-8 (if you're sure you let the browser know about it somehow) – mykhal Feb 15 at 9:35
Closure Compiler

Closure Compiler is a JavaScript optimizing compiler. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls. It is used in many of Google's JavaScript apps, including Gmail, Google Web Search, Google Maps, and Google Docs.

Try it out!

It's easy to try the compiler through our web application at http://closure-compiler.appspot.com/

Get the Compiler

Download the compiler at http://closure-compiler.googlecode.com/files/compiler-latest.zip or using Maven.

The zip file contains a README with quick instructions to get you started.

User Documentation

You can read more about Closure Compiler at http://code.google.com/closure/compiler/.

We also have a few low-key wiki pages at http://code.google.com/p/closure-compiler/w/list. Please suggest new ones if you see anything missing.

Developer Documentation

The Closure Compiler javadocs are available at http://closure-compiler.googlecode.com/svn/trunk/javadoc/index.html

You can browse the source at http://code.google.com/p/closure-compiler/source/browse/#svn/trunk

We accept patches

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.