A free tool for making JavaScript download and run faster

Closure Compiler

Join our mailing list

Stay up to date with latest software releases, news, software discounts, deals and more.

Subscribe
Download Closure Compiler 20240317

Closure Compiler

  -  13.3 MB  -  Open Source
  • Latest Version

    Closure Compiler 20240317 LATEST

  • Review by

    Daniel Leblanc

  • Operating System

    Windows 7 / Windows 8 / Windows 10 / Windows 11

  • User Rating

    Click to vote
  • Author / Product

    Google / External Link

  • Filename

    closure-compiler-v20240317.jar

Closure Compiler is an advanced compiler of Java projects that can provide its users to optimize many aspects of JavaScript code by checking the syntax, variable references, eliminating dead code areas, and more.

This google-signed compiler can in some cases dramatically optimize JavaScript apps, making them less memory and computation heavy and thus able to run better without the need for wasted resources. Built by the Google corporation in order to help programmers all over the world to embrace the Java programming language that is today powering much of the modern cloud-based infrastructure, web services, and client-side tools.

While many compilers go with the route of translating the user's code to machine language and then trying to find the best optimizations, Closure Compiler works in a different way. Instead, it analyzes the complete available JavaScript source code in a project and simply searches for any type of error it can find. This can include everything from simple syntax errors, illegal operations, various looping errors, dangerous operations, and more. It can even completely delete dead code sections. The end result is an optimized code that is free from errors, can run without bugs, and can take more advantage of the available hardware without losing resources on parts of the app that can be safely eliminated.

The true power of the optimization comes in a form of re-writing lines in order for them to be executed faster and more reliably. Closure Compiler can do things like renaming basic symbols or parameters, removing unnecessary elements (comments), removing invalid references, checking data types, highlighting common errors, and much more.

In the end, the final result of putting a JavaScript code through Closure Compiler is a faster and more optimized app that will be smaller in size, faster to execute, more stable in real-world usage, and all of that without any effect on the code functionality. Users who want to review the optimization steps that this app has made can even read in-depth reports and learn what parameters got renamed, what formats changed, and more.

Closure Compiler is 100% FREE and can be used on both modern and some legacy versions of Windows OS (Windows 7, 8, 10, 11 both 32-bit and 64-bit).

What's new in this version:

Closure Compiler 20240317
- Add --variable_map_input_file and --property_map_input_file options to the OSS command-line runner
- fix infinite recursion in certain template type checks
- Moved the warning/error on use of string continuations to be a linter-only check
- Error on unrecognized Closure .base method calls instead of silently ignoring them, which would previously lead to property renaming bugs
- Rename removeDeadCode to removeUnreachableCode. remove_dead_code is replaced by remove_unreachable_code
- "dead code" is extremely ambiguous where as "unreachable" is more often used when talking about CFG guided code removals
- Add externs for maps api v3.56
- Define --browser_featureset_year 2024 based on Chromium 120, Firefox 121, and Safari 17.2. For the first time, all major browsers have surpassed Closure Compiler's support for emitting JS, so users opting into BFY 2024 may see more modern JS in their binaries over time as support for emitting additional JS language features lands in Closure Compiler. And as always, userland code can also use goog.FEATURESET_YEAR to produce binaries specialized for modern browsers.
- For more info on newly supported features
- Notable features newly supported in 2024 browsers include: Offscreen Canvas, AVIF images, the loading attribute, Import Maps, CSS Subgrid, LCH and Lab color values, and tons of CSS features.
- Merge #4134 by ecrider: Add missing AbortSignal static methods.
- In addition, this also changes AbortSignal from @interface to @constructor, and add the missing property implementation (addEventListener, removeEventListener, dispatchEvent) as it was not required before as an interface.
- Allow $ in @template names
- Fix inlining bug treating assignments in chunks as unconditionally loaded
- Added externs and polyfills for Array.findLast, Array.findLastIndex, and TypedArray variants
- Preserve unions of different ReadonlyArray types instead of using raw type
- Detect toggle usage via goog.module.get.
- Fix transpilation of block-scoped vars in loop bodies to no longer leak data from one iteration into the TDZ of the next iteration
- Fix MakeDeclaredNamesUnique so that it does not generate conflicting names
- Allow unused void operator without a suspicious code warning
- Files annotated with @nocoverage will not be instrumented for code coverage
- Speed up escaping JavaScript
- Generate one conformance report for each chunk
- Allow subclasses to broaden visibility of overridden methods
- Support tested assignments of classes (e.g. let Foo = Foo_1 = class Foo{}). This is newly emitted by TypeScript 5.2 for decorated classes, which reference a static property of itself.
- Fix enclosing @ngInject detection for TypeScript 5.2 emit for decorated classes
- Fix case where goog.forwardDeclare conformance error message would omitted the goog.forwardDeclared type name and just print "NoResolvedType" instead
- Fixed bug where optimizations would, in rare cases, copy static properties between unrelated classes. This is unlikely to be a breaking change since those properties should later be dead-code eliminated, and any accidental references should cause a missing property error.
- don't crash when emitting member function defs whose names refer to collapsed properties


Closure Compiler 20231112
- Files annotated with @nocoverage will not be instrumented for code coverage
- Speed up escaping JavaScript
- Generate one conformance report for each chunk
- Allow subclasses to broaden visibility of overridden method
- Support tested assignments of classes (e.g. let Foo = Foo_1 = class Foo{}). This is newly emitted by TypeScript 5.2 for decorated classes, which reference a static property of itself
- Fix enclosing @ngInject detection for TypeScript 5.2 emit for decorated classes
- Fix case where goog.forwardDeclare conformance error message would omitted the goog.forwardDeclared type name and just print "NoResolvedType" instead
- Fixed bug where optimizations would, in rare cases, copy static properties between unrelated classes. This is unlikely to be a breaking change since those properties should later be dead-code eliminated, and any accidental references should cause a missing property error
- don't crash when emitting member function defs whose names refer to collapsed propertie


Closure Compiler 20230802
- RemoveUnusedCode will now generate an "unremovable.log" file when debug logging is enabled. It contains a line for each non-removed variable stating why it could not be removed.
- Improve constant inference in BanElementSetAttribute
- Removed support for referencing goog.module exports or local variables by the compiler-mangled name in JSDoc, e.g. @type {!module$exports$foo}. Use goog.require/goog.requireType instead.
- Add support for the @pureOrBreakMyCode jsdoc annotation in the RemoveUnusedCode pass to help it decide if side effects can be removed
- Update the latestEcmaScript in JSCompiler config to return ES2021
- Respect constantness indicated by @const when checking setAttribuite violations
- Add ReplaceToggles pass, which replaces calls to goog.toggle(num) with a direct lookup on the goog.TOGGLES_ bitset


Closure Compiler 20230502
- Add externs for maps api v3.53
- Improve pathological edge case in InlineSimpleMethods performance


Closure Compiler 20230411
- Made performance improvement that also slightly improves property disambiguation (i.e. type-based property renaming). This is generally expected to be a safe change, but in some edge cases could break code that has incorrect type annotations.
- Fixed bug in polyfill isolation that sometimes caused polyfill of Reflect.construct to be used on ES6+ compatible browsers
- Fix inlining goog.reflect.objectProperty
- InlineAndCollapseProperties does a better job of inlining destructuring patterns, which can improve code sizes when targeting ES2015+ output.
- Fix a bug in CoalesceVariableNames pass where we generate incorrect code with usePseudoNames=true
- Remove the setCssRenamingMap/getCssRenamingMap APIs from Compiler/AbstractCompiler (but leave the ones in CompilerOptions where they make more sense).
- Add a new compiler option to force let/const transpilation
- Never suppress unrecognized type errors for goog.provide/goog.module namespaces. Previously, if running the compiler in a mode that sorts or prunes unused dependencies, all goog.module & goog.provide namespaces are "forward declared", so the compiler won't report unrecognized type errors for those namespaces.


Closure Compiler 20230228
- Deleted CodingConvention::isInlinableFunction. The standard way of preventing inlining for a function is now the @noinline annotation in JSDoc.
- Don't register types mismatch if actual type satisfies any of required union's alternates
- Add externs for maps api v3.52
- A for-of loop transpiled down to ES5 should throw a TypeError if the object to be iterated has neither a Symbol.iterator property nor a length property.
- Allow @nosideeffects in function jsdoc outside of externs, and use it as a signal in PureFunctionIdentifier to treat the function as pure.
- Prevent mutations to ReadonlyArrays.
- Correct the name of SourceBuffer mode property from externs.
- Fix behavior of Array.prototype.flat() and Array.prototype.flatMap() for sparse arrays.


Closure Compiler 20230206
- Correct the name of SourceBuffer mode property from externs
- Fix behavior of Array.prototype.flat() and Array.prototype.flatMap() for sparse arrays
- Avoid using regex parser unless bundling or pruning unused inputs. This is expected to be a small speedup and not a breaking change.
- Define --browser_featureset_year 2023 based on Chromium 108, Firefox 108 (jinx!), and Safari 16.2. Due to a missing feature in Safari, this will still emit ES2021, but userland code can still switch off of an expectation of more recent browsers.
- Removed multiple deprecated compiler options: setInlineFunctions(boolean) was replaced by setInlineFunctions(Reach), setMoveFunctionDeclarations was replaced by setRewriteGlobalDeclarationsForTryCatchWrapping, and setCssRenamingWhitelist was replaced by setCssRenamingSkiplist
- Speed up bundle generation by only relying on the regex-based fast parse. This is not expected to be a behavioral change


Closure Compiler 20230103
- Avoid checking weak sources when running CheckConformance to avoid false positives when sources are pulled in only for type references
- Report parse error on illegal LHS of += and similar operators
- Rename Rhino Node isQuotedString and setQuotedString methods to better indicate the methods are for checking quoted property keys, not string literals with quotes. isQuotedString -> isQuotedStringKey and setQuotedString -> setQuotedStringKey.
- Normalize arrow functions when transpiling classes with forced class transpilation Unnormalized arrows are not handled in ES6ExtractClasses pass and typically get normalized when the pass runs. But with forced class transpilation turned on, the normalization is skipped causing JSCompiler to crash.
- Removes an old compiler feature preferNewLineAtEndOfFile that would cause the code printer to output additional whitespace between files when printing. There are no more use cases for this feature that was added to workaround an issue in source map composition in an old serving system.
- Add debug logging annotation to observe inferred types
- Allow @suppress JSDoc on every statement, as opposed to only declarations/assignments
- Make IteratorIterable and IIterableResult covariant
- Add externs for maps api v3.51
- Makes ReadonlyArray covariant
- Fixes value type inference on for-of over unions
- Handle default parameter assigned to class in ES6 class transpilation
- Corrects type inference for subscript access on unions
- Add conformance check for BANNED_STRING_REGEX
- Add typings on ReadonlyArray for ES6 Array methods
- Fixed bug present if using --language_out=ECMASCRIPT_2015 or higher and the "rename prefix namespace" functionality. Previously, functions declared in blocks in the global hoist scope were accidentally hoisted into the global scope. Now they are correctly treated as block-scoped.


Closure Compiler 20221102
- Improve the compiler's license tracking so that input files with licensed code that end up unused after optimizations don't force the retention of the license texts
- Moved the com.google.javascript.jscomp.parsing.parser.util.format package to the more central location of com.google.javascript.jscomp.base.format
- Java API change: deleted two of the five JSError.make variants that take explicit CheckLevels and override CheckLevel of the associated DiagnosticType
- Treat 'codebase' and 'data' as security sensitive attributes in the conformance checks
- Remove "runtime type check" support
- This feature of the compiler has long been under used and under maintained. At this time we believe our efforts would be better spent elsewhere.
- Deleted unused class com.google.javascript.rhino.SimpleErrorReporter
- We now avoid creating an unshaded deploy jar that contains copies of dependencies instead of using dependencies from Maven.
- Compiler_uberjar_deploy.jar has replaced compiler_unshaded_deploy.jar
- In conformance, treat setAttributeNS with a null namespace the same as setAttribute
- Allow @suppress {dangerousUnrecognizedTypeError} in JS code to suppress JSC_UNRECOGNIZED_TYPE_ERRORs
- Simplify logic in InlineSimpleMethods to fix compiler crash


Closure Compiler 20221004
- Lint warnings about usage of var can now be suppressed with @suppress {lintVarDeclarations}
- Allow dead-code elimination of (void 0)?.() in ES2022 output mode
- Fixed bug where invalid super property and this references within the arguments of a super(...) constructor call were not reported
- Added a compiler flag --assume_no_prototype_method_enumeration, which is mapped to CompilerOptions.crossChunkCodeMotionNoStubMethods, which controls CrossChunkMethodMotion#noStubFunctions. When it is set to true, it will allow the compiler to move a prototype method declaration into a deeper chunk without creating stub functions in a parent chunk.
- Fixed bug where references to local variables named exports in a goog.module (e.g. function f(exports) {}) could be mangled


Closure Compiler 20220905
- Move CFG management out of NodeTraversal and into common callback base class (NodeTraversal.AbstractCfgCallback)
- Add externs for maps api v3.50
- Modifications to make the missing property and property creations checks on union stricter. A property must be known on all members of a union (excluding null or undefined). Previously, existance on any member of the union was sufficient.
- Fix incorrect optimization that inlines super.x() to super.x


Closure Compiler 20220803
- Corrected a bug that could cause the source map info for a qualified name reference to point to the location of the qname's definition instead of the location of the reference itself
- Define a new DiagnosticType ILLEGAL_PROPERTY_CREATION_ON_UNION_TYPE that can be suppressed using strictMissingProperties
- Modify Closure Compiler open source build to pull in org.jspecify to add @Nullable annotations
- Remove support for @hidden as a part of message translation
- Always gather source map information for stages 1 and 2
- It doesn't make sense to specify the output source map location for the early stage invocations of a multi-stage build, but leaving it unspecified caused the compiler to lose type information that should have been gathered in those stages


Closure Compiler 20220719
- Make more property-based dead code elimination back off on reflective accesses of a property name, like goog.reflect.objectProperty('m', c)
- Update GOOG_PROVIDE_REQUIRE_PATTERN and its usage to support multi-lines declarations
- Make 2-lines module declarations recognizable by JsFileRegexParser
- Fix bug where types shadowing goog.module imports were not resolved
- Fixed bug where function arguments with side effects were sometimes deleted
- Improved dead-code elimination for special case of new class {}
- When performing a partial (stage 1 or stage 2) compilation, the compiler compiler exits with a 0 status only when no errors are reported. The exit status contains the number of errors reported up to a maximum of 127.
- This was always the intended behavior, and is consistent with single-stage compilation. A recent change accidentally caused it to exit with 0 for partial compilations regardless of any errors reported.
- Added extern and polyfill for Object.hasOwn. Confirmed the TS declarations exist in the standard .d.ts files.
- Updates to allow use of the 'd' flag for regular expressions and the indices values it creates. Currently, input and output language level need to be ES_NEXT to avoid an error message from the compiler for using this feature.
- CLOSURE_DEFINES values may now be specified with separate invididual property assignments, rather than requiring them to be in a single object literal (though it must still be in the top-level/global scope). Duplicate keys produce an error.
- Add extern definition for Object.hasOwn(object,property) method
- Added BanSettingAttributes conformance check
- Added recognition, validation, and error of the new /d flag for RegExps as part of ES_2022
- Enable support for the Error constructor {cause: err} argument and Error.prototype.cause feature added in ES2022. NOTE: This behavior is not polyfilled. We only ensure that the compiler will not complain about the argument.
- Rework pass config to aways run VarCheck pass after VariableReferenceCheck pass. This may cause more errors to surface in single-file transpilation mode.


Closure Compiler 20220601
- Correct useless label optimization when a label is nested within a label
- Compilation error on duplicate module and provide names
- Fix crash with label'd do/while blocks

Support @provideAlreadyProvided during typechecking. Here we are doing a couple of things:
- avoid creating a default namespace object type when a goog.provide is annotated with
- add some logic find the type of the implicitly assigned namespace by looking up the object from the parent namespace object. The second is valid as @provideAlreadyProvided is only useful if the parent namespace is assigned a value that contains the child namespace.
- Add externs for maps api v3.49
- Add a flag --emit_async_functions_with_zonejs to relax the restriction on disallowing --language_out=ES_2017 together with Zone.js
- Fix cases of incorrect constant folding for the coalesce operator ??
- Move "public class fields" feature down from ES_NEXT to UNSTABLE. Since ES_NEXT is supposed to be for features that are fully supported, and transpilation of public fields is not yet fully implemented, by our accounting it should only be considered UNSTABLE and not yet ES_NEXT. We do intend to add support for transpilation and will move the feature back to ES_NEXT when we do.
- Fix false positive "missing @const annotation" lint when using destructuring assigns
- Fix potential misoptimization of variables/properties in a logical assignment. Some compiler passes failed to realize that such assignments could evaluate to a mutable value and so would delete code incorrect.
- Set --angular_pass to true by default
- Refactor pass building so that there is a central way to check conditions for the pass. This is step toward making it easier to configure modes for the passes (transpile only, renaming only, etc)
- Made typechecker change to fix edge cases where @implements {I} was treated as @implements {I- Fix handling of tagged template literals side-effect detection to consider contained expressions
- Improves performance and memory usage of ControlFlowAnalysis
- Fix an issue when where source text could be retained in memory throughout the compilation process
- Fix an issue when resolving non-trivial unions when complex types, where the check for existence of template types would be n^2


Closure Compiler 20220502
- Allow specification of example text and original code text for message placeholders in goog.getMsg()
- Enabled "unnecessary escape" lint warnings in untagged template literals
- Add a new rule to OptimizeParameters to trim trailing undefined parameters from calls where the callee doesn't use rest parameters or access the arguments object. Should save code size in most applications since inlining functions that pass through optional params tends to create this pattern.
- Remove references to goog.mixin now that it has been removed
- Loosen the constraints on goog.module.get so that only assignments to global variables are banned
- Add support for @provideAlreadyProvided
- Make BanSetAttribute less restrictive by allowing certain "effectively constant" attribute names
- Only enable "unnecessary escape" warnings in the linter
- Support matching types imported from a JS boundle in conformance
- Fixed parser crash on multiline string literals with invalid escape sequences
- Modify for-await-of to only exist inside an async function


Closure Compiler 20220405
- Allow specification of example text and original code text for message placeholders in goog.getMsg().
- Enabled "unnecessary escape" lint warnings in untagged template literals
- Add a new rule to OptimizeParameters to trim trailing undefined parameters from calls where the callee doesn't use rest parameters or access the arguments object. Should save code size in most applications since inlining functions that pass through optional params tends to create this pattern.
- Remove references to goog.mixin now that it has been removed.
- Loosen the constraints on goog.module.get so that only assignments to global variables are banned.
- Add support for @provideAlreadyProvided
- Make BanSetAttribute less restrictive by allowing certain "effectively constant" attribute names.
- Only enable "unnecessary escape" warnings in the linter.
- Support matching types imported from a JS boundle in conformance.
- Fixed parser crash on multiline string literals with invalid escape sequences.
- Modify for-await-of to only exist inside an async function.

Join our mailing list

Stay up to date with latest software releases, news, software discounts, deals and more.

Subscribe