Questions tagged [google-closure-compiler]

Google Closure Compiler compiles a typed superset of modern JavaScript to a target version of JavaScript, applying type checking, dead code elimination, minification and other improvements.

The Closure Compiler is a tool for making JavaScript download and run faster. It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls.

The Closure Compiler has three optimization modes: whitespace only, simple optimizations, and advanced optimizations. The first two are safe for all JavaScript. The latter one imposes restrictions on JavaScript usage, but it is where Closure Compiler shines and the valuable type checking, dead code removal, and better minification.

1178 questions
16
votes
2 answers

Closure Compiler + Typescript

I want to use Typescript and then Closure Compile (advanced compilation) to target ES5 and minify the output. Do I have to use tsickle in place of tsc? It lacks support for all the options tsc has, and is far ambitious in that it wants to translate…
Paul Draper
  • 78,542
  • 46
  • 206
  • 285
16
votes
4 answers

Preventing closure compiler from renaming certain variables

I have a javascript file with a global object that must not be renamed (_gat from the Google Analytics async tracker). This object must not be renamed by the Google Closure Compiler as Google Analytics looks for a variable with this specific…
phidah
  • 5,794
  • 6
  • 37
  • 58
16
votes
3 answers

issue regarding trailing commas in JavaScript

Possible Duplicate: Internet Explorer, Closure Compiler and Trailing Commas I've tried compressing my javascript code using the Closure Compiler and the compilation of the code generated these two errors: JSC_TRAILING_COMMA: Parse error. IE8…
Andrei Oniga
  • 8,219
  • 15
  • 52
  • 89
14
votes
7 answers

Compress all file .js with Google Closure Compiler Application in one File

I would like to Compress all my file .js in a same directory in one file with Google Closure Compiler in a command line. For one file it's : java -jar compiler.jar --js test.js --js_output_file final.js But I didn't find in the doc how put my other…
j3j3
  • 143
  • 1
  • 1
  • 4
14
votes
6 answers

How to minify JavaScript like Google Analytics?

Most of you are probably familiar with this little tracking code offered by Google Analytics.