Closure Compiler is a JavaScript compiler and optimizer that transforms JavaScript code to improve download speed and runtime performance.
The tool addresses the problem of JavaScript file size and execution efficiency by parsing JavaScript, analyzing it, removing dead code, and rewriting the remaining code to be smaller and faster. It operates as a true compiler, translating from JavaScript to optimized JavaScript rather than to machine code. Beyond optimization, it performs static analysis to check syntax, validate variable references, detect type errors, and warn about common JavaScript pitfalls.
Closure Compiler is best suited for projects where code can be written specifically with the compiler in mind, particularly those using the goog.module() and goog.require() module system. The tool excels in ADVANCED mode, which performs aggressive whole-world optimization by removing dead code and renaming variables and properties to minimize output size. However, it requires visibility into all uses of global variables, exported variables, and property names across the entire codebase. Projects must maintain consistent property access patterns—using either dot notation or bracket notation, but not both for the same property—to avoid broken output. The README explicitly notes that other tools perform comparably for non-ADVANCED compilation modes and are better integrated into the broader JavaScript ecosystem, making them preferable for those use cases. Closure Compiler assumes a web browser target environment by default, with limited and unsupported NodeJS compatibility.
The project maintains active development with regular commits addressing bug fixes and feature improvements. The codebase shows consistent engagement with issues and pull requests from the community. Development focuses on maintaining the compiler's core optimization capabilities while acknowledging the tool's specialized nature and the constraints it imposes on codebases.