🗜️ JS Minifier

JS Minifier - Remove comments and extra whitespace from JavaScript for a quick size reduction, without renaming variables. Free, browser-only.

📐 工作原理與說明
依次執行:刪除塊註釋;刪除行註釋;把連續空白壓縮為單個空格;去掉等號、加號、減號、乘號、除號、取餘、尖括號、花括號、逗號、分號、冒號、圓括號與方括號等符號兩側的空白;再次壓縮空白並去掉首尾空白
壓縮 JS 程式碼以減小體積。
  • 手段:去空白與註釋、縮短識別符號、刪除不可達程式碼、合併常量。
  • 驗證:壓縮後必須做功能迴歸,確認行為未改變。
  • 疊加:與 gzip/brotli 傳輸壓縮疊加使用,收益更明顯。
  • 許可:保留 /*! … */ 形式的許可宣告,滿足開源協議要求。

Formula & Standard References

Item Formula / Note Source / Standard
Lexical safety removing whitespace must not change ASI outcomes ECMA-262
Name mangling local names may shorten; exports and globals may not ECMA-262
Equivalence behavior must match, especially this binding and eval ECMA-262
⚠️ 使用說明與注意事項

📋 建議

僅做快速瘦身可用本工具;CI 流水線裡推薦整合 Terser 以獲得更優壓縮率與 tree-shaking。