研究过程: 1、先强烈鄙视一下哪些随便转载文章的家伙,给我制造了很大的麻烦!!网上很多帖子都不靠谱。。 2、首先想了解jquery使用什么压缩的, 网上找了半天,说法不一样,后来还是在jquery官网的最频繁问题中找到了答案,但这已经是绕了一大圈之后的事情了。 (a)根据我看到的一些信息,jquery压缩最早是用 Dean Edwards" Packer 进行压缩的,大概是在jquery1.3版本吧(我在一本jquery的书上看到的。)。这个东西出来的比较早,作者好像也是头 大牛,目前是3.0版本,好像是在线版本,我自己把代码去他网站上压缩,无法使用,会出错误。 (b)后面jquery换成yuicompressor 进行压缩,具体哪个版本不太清楚,有篇文章的作者说:他去jquery的svn中找了一下,发现有yuicompressor 的文件,然后他特意用jQuery.js试了一下,处理过的文件和jQuery.min.js一模一样。原帖地址。 (c) 偶滴神啊,最后我在jquery官网找到了这么一段话。How do I compress my code?
内容如下: Generally the best way to do it is to use the Google Closure Compiler (used by jQuery) or YUI compressor. jQuery provides a pre-minified version of jQuery for your convenience. Packing JavaScript using Dean Edwards" Packer (specifically using the base64 encode) is not recommended, as the client-side decoding has significant overhead that outweighs the file-size benefits. 大致意思是说:jquery用的是google的开源js压缩工具,Google Closure Compiler和YUI compressor 是目前最佳的js压缩方式。 Dean Edwards‘ packer 是不推荐使用的!!