透過集合功能整理內容
你可以依據偏好儲存及分類內容。
什麼是 Closure 編譯器?
Closure 編譯器可加快 JavaScript 的下載和執行速度。不是從來源語言編譯為機器碼,而是從 JavaScript 編譯為更優質的 JavaScript。這項工具會剖析 JavaScript、進行分析、移除無效程式碼,並重新編寫及縮減剩餘的程式碼。也會檢查語法、變數參照和型別,並警告常見的 JavaScript 陷阱。
如何使用 Closure 編譯器?
您可以將 Closure 編譯器做為:
您可以透過指令列執行的開放原始碼 Java 應用程式。您可以透過 Bazel 依附的程式庫。
NPM 套件
如要開始使用編譯器,請參閱下方的「如何開始」。
使用 Closure Compiler 有哪些優點?
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eThe Closure Compiler is a tool that optimizes JavaScript for faster download and execution by analyzing, removing dead code, and minimizing the remaining code.\u003c/p\u003e\n"],["\u003cp\u003eIt offers benefits such as improved efficiency by reducing file size and enhanced code checking by providing warnings for potential issues.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize the Closure Compiler through a command-line application, a simple web interface, or by integrating it into their development workflow via the provided resources and documentation.\u003c/p\u003e\n"]]],[],null,["What is the Closure Compiler?\n-----------------------------\n\n\nThe Closure Compiler is a tool for making JavaScript download and run\nfaster. Instead of compiling\nfrom a source language to machine code, it compiles from JavaScript to\nbetter JavaScript. It parses your JavaScript, analyzes it, removes\ndead code and rewrites and minimizes what's left. It also checks\nsyntax, variable references, and types, and warns about common\nJavaScript pitfalls.\n\nHow can I use the Closure Compiler?\n-----------------------------------\n\n\nYou can use the Closure Compiler as:\n- An open source Java application that you can run from the command line.\n- A library you can depend on via Bazel.\n- An NPM package\n- To get started with the compiler, see \"How do I start\" below.\n\nWhat are the benefits of using Closure Compiler?\n------------------------------------------------\n\n - **Efficiency.** The Closure Compiler reduces the size of\n your JavaScript files and makes them more efficient, helping your\n application to load faster and reducing your bandwidth needs.\n\n - **Code checking.** The Closure Compiler provides warnings\n for illegal JavaScript and warnings for potentially dangerous\n operations, helping you to produce JavaScript that is less buggy and\n easier to maintain.\n\n How do I start?\n ---------------\n\n\n - Download the most recently released JAR file from the [Maven repository](https://mvnrepository.com/artifact/com.google.javascript/closure-compiler).\n - Work through the [Application\n Hello World](/closure/compiler/docs/gettingstarted_app).\n - Read about [Advanced\n compilation](/closure/compiler/docs/api-tutorial3).\n - Explore [the project's source code](https://github.com/google/closure-compiler).\n\n \u003cbr /\u003e"]]