使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
什么是 Closure Compiler?
Closure 编译器是一种可加快 JavaScript 下载和运行速度的工具。它不是从源语言编译为机器代码,而是从 JavaScript 编译为更好的 JavaScript。它会解析您的 JavaScript 代码、对其进行分析、移除无效代码,并重写和最小化剩余代码。它还会检查语法、变量引用和类型,并针对常见的 JavaScript 陷阱发出警告。
如何使用 Closure Compiler?
您可以使用 Closure 编译器,如下所示:
一个可通过命令行运行的开源 Java 应用。
您可以通过 Bazel 依赖的库。
NPM 软件包
如需开始使用编译器,请参阅下文中的“如何开始”。
使用 Closure 编译器有哪些优势?
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):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"]]