RevealTheme logo

JavaScript壓縮工具

基礎的JavaScript壓縮:移除註解和不必要的空白。生產環境請使用真正的壓縮工具(Terser、esbuild)。

如何使用本工具

  1. 1

    Paste or type your JavaScript into the input textarea.

  2. 2

    The minified output appears instantly in the panel below as you type — there is no button to press.

  3. 3

    Check the size readout (original length, an arrow, and minified length) to see how much was removed.

  4. 4

    Select the text in the output box and copy it manually into your file.

什麼是JavaScript壓縮工具?

JavaScript壓縮可減小程式碼套件體積並縮短剖析時間。本工具執行基礎的空白和註解移除。對於生產環境的程式碼套件,請使用Terser、esbuild或SWC:它們會進行變數名稱混淆和死碼消除,從而產生體積大幅縮小的輸出(通常可減少60%到80%)。

常見使用場景

  • Quickly shrinking a short, comment-heavy snippet before pasting it into a tight inline <script> tag.

  • Stripping comments out of a code sample to share a compact version in a chat or gist.

  • Estimating roughly how much comment and whitespace overhead a small file carries before setting up a real build.

  • Cleaning up a hand-written configuration object or constant block that has no strings containing slashes.

  • Demonstrating to students or teammates what basic comment and whitespace removal looks like versus a real compiler.

  • Minifying a tiny utility function for a bookmarklet where pulling in a full toolchain is overkill.

常見問題

它和Terser相比如何?
Terser要積極得多:變數名稱混淆、死碼消除等。本工具只移除註解和空白。
這會破壞我的程式碼嗎?
只有當你的JS存在語法問題時(在含義不明確的位置缺少分號)才會。現代JavaScript是安全的。

相關工具