有没有好的 JavaScript 压缩器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/3520285/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a good JavaScript minifier?
提问by user160820
What JavaScript minifier do you recommend?
你推荐什么 JavaScript 压缩器?
回答by Tim Down
Active
积极的
Deprecated
已弃用
Google Closure Compiler generally achieves smaller files than YUI Compressor, particularly if you use the advanced mode, which looks worryingly meddlesome to me but has worked well on the one project I've used it on:
Google Closure Compiler 通常实现比 YUI Compressor 更小的文件,特别是如果您使用高级模式,这对我来说看起来很麻烦,但在我使用过的一个项目中运行良好:
Several big projects use UglifyJS, and I've been very impressed with it since switching.
几个大项目都在使用 UglifyJS,自从切换以来,我对它印象非常深刻。
回答by 2ndkauboy
If you are using PHP you might also want to take a look at minifywhich can minify and combine JavaScript files. The integration is pretty easy and can be done by defined groups of files or an easy query string. Minified files are also cached to reduce the server load and you can add expire headers through minify.
如果您正在使用 PHP,您可能还想看看minify,它可以缩小和组合 JavaScript 文件。集成非常简单,可以通过定义的文件组或简单的查询字符串来完成。缩小的文件也被缓存以减少服务器负载,您可以通过 minify 添加过期标头。
回答by chilts
JavaScript Minifiergives a good API you can use programatically:
JavaScript Minifier提供了一个很好的 API,您可以以编程方式使用:
curl -X POST -s --data-urlencode 'input=$(function() { alert("Hello, World!"); });' http://javascript-minifier.com/raw
Or by uploading a file and redirecting to a new file:
或者通过上传文件并重定向到新文件:
curl -X POST -s --data-urlencode '[email protected]' http://javascript-minifier.com/raw > ready.min.js
Hope that helps.
希望有帮助。
回答by Kris van der Mast
There are several you can use/try:
您可以使用/尝试几种方法:
- YUI compressor
- jsmin
- Microsoft Ajax minifier(has hypercrunching)
- YUI压缩机
- jsmin
- Microsoft Ajax minifier(具有超处理能力)
回答by austincheney
Pretty Diff - http://prettydiff.com/?m=minify
回答by Filipe Costa
Sometimes i use this: http://closure-compiler.appspot.com/home
有时我使用这个:http: //closure-compiler.appspot.com/home
回答by MartinPalermo
This tool: jscompressor.comis pretty good.
这个工具:jscompressor.com很不错。

