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

Font Awesome Icon Sizes

Font Awesome I...

pexelsphotoicon5 紀錄一下Font Awesome icon尺寸設定 faxs fa...

PHP 字串字數計算並隱藏

PHP 字串字數計算並隱藏

fontphoto55 使用PHP substr函式可以做字串切割,但在遇到中文字時記得使用mbsu...

jQuery resize取得瀏覽器目前視窗寬度

jQuery resize取...

pexelsphotokeyboard5 在使用CSS調整RWD顯示時~ 也可以使用javascri...

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