可靠且方便的 JavaScript 压缩器
我偶尔会写 JavaScript 代码。我有兴趣缩小它以获得更好的性能,但我不打算在这方面花费太多时间,特别是在测试缩小结果方面。
我找到了这个在线服务: http://www.lotterypost.com/js-compress.aspx
有几个问题:
- 靠谱吗?
- Microsoft AJAX minifier 与 YUI Compressor,哪个是最佳选择?
- 还有其他类似的在线工具可以推荐吗(为什么它比上面的链接更好)?
I occasionally write JavaScript code. I am interested in minifying it for better performance, but I don't plan to spend to much time on that, especially in testing the minified result.
I found this online service:
http://www.lotterypost.com/js-compress.aspx
So a couple questions:
- Is it reliable?
- Microsoft AJAX minifier vs. YUI Compressor, what's the best option?
- Any other similar online tool to recommend (and why is it better than the above link)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Google 的闭包编译器
是一个优秀的 Javascript 压缩器和编译器。它分析代码并报告可检测到的错误。它删除了冗余空间和未引用的代码,并将对象重命名为尽可能短的名称。您只需将属于一个 HTML 页面的所有 Javascript 文件编译在一起即可。
Google's Closure Compiler
is an excellent Javascript minifier and compiler. It analyzes the code and reports the detectable errors. It removes redundant space and unreferenced code, and renames objects to shortest possible names. You just need to compile together all Javascript files that belong to one HTML page.
您发布的那个链接恰好也是我使用的链接。
使用 MS AJAX Minifer。比 yui 好多了。除此之外:
http://stephenwalther .com/blog/archive/2009/10/16/using-the-new-microsoft-ajax-minifier.aspx:
好吧,如果您不相信我,请运行您的源代码(如果您没有实际的源代码要测试,只需在 http://code.jquery.com/jquery-1.6.2.js) 通过两者,看看哪个更“缩小”。
==
Google 有 Google Closure 编译器,但它会分析您的代码并删除未引用的代码(以进一步减小结果文件的大小)。然而,通常这不是您想要的,因为即使该文件中没有引用函数/变量,它也可能从构成您站点的其他 js 文件中引用)
That link you post happens to be the one that I use too.
Use the MS AJAX Minifer. It's way better than the yui one. besides:
http://stephenwalther.com/blog/archive/2009/10/16/using-the-new-microsoft-ajax-minifier.aspx:
Well if you don't trust me, run your source code (if you don't have an actual source code to test, just grab the source at http://code.jquery.com/jquery-1.6.2.js) through both and see which is more "minified".
==
Google has the Google Closure Compiler but it analyzes your code and removes unreferenced code (to furthur reduce the size of the resultant file). However usually this is not what you want because even though the functions/variables are not referenced within that file, it may be referenced from your other js files that make up your site)