可靠方便的JavaScript缩小器 [英] Reliable and convenient JavaScript minifier

查看:145
本文介绍了可靠方便的JavaScript缩小器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶尔会编写JavaScript代码。我有兴趣缩小它以获得更好的性能,但我不打算花太多时间,特别是测试缩小的结果。

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.

我在网上找到了这个服务:
http://www.lotterypost.com/js-compress.aspx

I found this online service: http://www.lotterypost.com/js-compress.aspx

所以有几个问题:


  • 它可靠吗?

  • Microsoft AJAX minifier与YUI Compressor,什么是最佳选择?

  • 推荐其他类似的在线工具(为什么它比上面的链接更好)?

推荐答案

您发布的链接恰好也是我使用的链接。

That link you post happens to be the one that I use too.

使用MS AJAX Minifer。它比yui更好。此外:

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


Microsoft Ajax团队(我在这个团队工作
)多年来一直在内部使用这个工具
。对于
示例,我们使用Microsoft Ajax
Minifier在发布之前缩小Microsoft Ajax
库。

The Microsoft Ajax team (I work on this team) has been using this tool internally for a number of years. For example, we use the Microsoft Ajax Minifier to minify the Microsoft Ajax Library before publishing it.

如果您不信任我,请运行您的源代码(如果您没有要测试的实际源代码,只需在 http://code.jquery.com/jquery-1.6.2.js )通过两者看看哪个更缩小。

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拥有Google Closure编译器,但它会分析您的代码并删除未引用的代码(以便更改结果文件的大小)。但通常这不是您想要的,因为即使函数/变量未在该文件中引用,也可以从构成您网站的其他js文件中引用它。

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)

这篇关于可靠方便的JavaScript缩小器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆