隨筆-57  評論-129  文章-0  trackbacks-0
          剛剛修正了一個JSA的bug。

          順便測試了一下文本壓縮的性能,和純packer 壓縮,ShrinkSafe+packer壓縮。
          壓縮大小:
          jquery-jsa-s.js(JSA的語法壓縮):29766
          jquery.compressed.js(ShrinkSafe語法壓縮):33992

          jquery-jsa-st.js(JSA的語法壓縮+文本壓縮):19526
          jquery-packer.js(Packer文本壓縮):20977
          jquery.compressed-packer.js(ShrinkSafe語法壓縮+Packer文本壓縮):21839

          有點奇怪的是,文本壓縮和語法壓縮是有一定互補性的,但是ShrinkSafe+Packer比單純的Packer文本壓縮效率還低??
          我想可能是ShrinkSafe做的一些語法補全(可省略的 {、}、;、),jQuery編碼的風格導致。

          Firefox測試數據(10次壓縮時間的毫秒數,連續5回測試數據)

          jquery-jsa-st.js:784
          jquery-packer.js:1265
          jquery.compressed-packer.js:1529

          jquery-jsa-st.js:718
          jquery-packer.js:922
          jquery.compressed-packer.js:766

          jquery-jsa-st.js:753
          jquery-packer.js:872
          jquery.compressed-packer.js:828

          jquery-jsa-st.js:1438
          jquery-packer.js:1484
          jquery.compressed-packer.js:1735

          jquery-jsa-st.js:687
          jquery-packer.js:1236
          jquery.compressed-packer.js:1234


          IE5 測試數據(連續三回測試數據)

          jquery-jsa-st.js:766
          --------------------------------------------------------------------------------
          jquery-packer.js:9765
          --------------------------------------------------------------------------------
          jquery.compressed-packer.js:10547


          jquery-jsa-st.js:671
          --------------------------------------------------------------------------------
          jquery-packer.js:9002
          --------------------------------------------------------------------------------
          jquery.compressed-packer.js:10265


          jquery-jsa-st.js:704
          --------------------------------------------------------------------------------
          jquery-packer.js:8232
          --------------------------------------------------------------------------------
          jquery.compressed-packer.js:10314

          總結

          文本壓縮是個比較耗時的操作,像JQuery這樣大的類庫普遍需要接近100毫秒的解壓時間。
          如果需要兼容IE5這種老古董,那么最好不要用packer的文本壓縮,太耗時。
          JSA1 對文本壓縮做了些改進,表現還可以。

          如果要計較腳本文本壓縮后的解壓開銷,建議使用JSA的語法壓縮,配合服務器端的gzip壓縮。
          不推薦dojo 的ShrinkSafe,原因是它的幾個安全問題。
          posted on 2007-05-24 09:28 金大為 閱讀(968) 評論(0)  編輯  收藏 所屬分類: JavaScript
          主站蜘蛛池模板: 防城港市| 华亭县| 东乌珠穆沁旗| 察哈| 惠东县| 麻阳| 循化| 马龙县| 中卫市| 洛川县| 兴义市| 仪征市| 淮北市| 囊谦县| 阳信县| 双辽市| 太白县| 益阳市| 哈尔滨市| 清水县| 三江| 新宁县| 威宁| 宣化县| 三明市| 谷城县| 保山市| 宜兰市| 镇江市| 洞头县| 桂林市| 白河县| 肃南| 南投县| 大同县| 温宿县| 岳阳县| 南靖县| 保亭| 龙门县| 林甸县|