Loading...

使用 Closure Compiler 幫 javascript 瘦身

Temperature: 0 °C

Mark ChangMark Chang
author_tools

JavaScript(縮寫為JS)是一種進階的、直譯的程式語言,且作為客戶端手稿語言在使用者的瀏覽器上運行,不需要伺服器的支援。維基百科
在建置網站系統的過程中,我們常常會使用JS來做為互動的效果,例如開關選單、瀏覽器卷軸下拉判斷、甚至使用AJAX傳遞變數,JS可說是無所不在。
也由於使用率的頻繁,JS也變成越來越肥大,就如同肥大的CSS一樣這將會影響到網站載入繪製時的速度。
CSS有可以協助瘦身的線上工具,那麼JS呢?

Closure Compiler
Closure Compiler 是 Closure Tools 的其中一項工具,它可以編譯 JS 的程式碼,在經過最佳化處理後,並產生高效能且最小化的 JS,讓網頁的載入速度與執行效能都可以提高。

該怎麼做?
1)首先將JS程式碼貼在編譯區。
2)或者你可以直接將JS的線上位置貼在網址列。
3)直接按下Compile,編譯好的程式碼會顯示在Compiled code區域。
4)將編譯好的程式碼複製貼上至原JS檔案裡即可。

使用 Closure Compiler 幫 javascript 瘦身
同樣的我們可以看到JS瘦身前瘦身後的壓縮率。

使用 Closure Compiler 幫 javascript 瘦身
做好JS的瘦身,可以有效提升網站執行效率。

以上紀錄~

#故事  #javascript  #Closure Compiler  
https://innstory.com/story-使用_Closure_Compiler_幫_javascript_瘦身-2829
javascript 免費資源

Prev
 當域名_DNS_尚未生效時如何預先設定及測試網站

Next
使用javascript_正規化判斷網址url是否正確 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

如何將mysql table auto_increment重設

如何將mysql table...

photo555 資料表裡的資料加加減減,一不小心突然驚覺當初的欄位長度設定的不夠⊙⊙ 當然,你可以...

使用PHP取得指定月份最後一天的日期

使用PHP取得指定月份最後一...

使用PHP要如何抓某個月份的最後一天 例如抓本月份的話可以使用下列範例: date(&#;Ymt&#...

javascript change css class

javascript cha...

javascript 使用classList是一個方便的替代方法,可以將元素的類列表作為空格分隔的字...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format