研究過程: 1、先強烈鄙視一下哪些隨便轉(zhuǎn)載文章的家伙,給我制造了很大的麻煩!!網(wǎng)上很多帖子都不靠譜。。 2、首先想了解jquery使用什么壓縮的, 網(wǎng)上找了半天,說法不一樣,后來還是在jquery官網(wǎng)的最頻繁問題中找到了答案,但這已經(jīng)是繞了一大圈之后的事情了。 (a)根據(jù)我看到的一些信息,jquery壓縮最早是用 Dean Edwards' Packer 進行壓縮的,大概是在jquery1.3版本吧(我在一本jquery的書上看到的。)。這個東西出來的比較早,作者好像也是頭 大牛,目前是3.0版本,好像是在線版本,我自己把代碼去他網(wǎng)站上壓縮,無法使用,會出錯誤。 (b)后面jquery換成yuicompressor 進行壓縮,具體哪個版本不太清楚,有篇文章的作者說:他去jquery的svn中找了一下,發(fā)現(xiàn)有yuicompressor 的文件,然后他特意用jQuery.js試了一下,處理過的文件和jQuery.min.js一模一樣。原帖地址。 (c) 偶滴神啊,最后我在jquery官網(wǎng)找到了這么一段話。How do I compress my code?
內(nèi)容如下: 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 是不推薦使用的!!