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
27
votes
5 answers

Getting closure-compiler and Node.js to play nice

Are there any projects that used node.js and closure-compiler (CC for short) together? The official CC recommendation is to compile all code for an application together, but when I compile some simple node.js code which contains a…
bukzor
  • 37,539
  • 11
  • 77
  • 111
26
votes
1 answer

My source-mapped breakpoints aren't working correctly in Google Chrome

I have created a concatenated, minified file through the Node.js wrapper for Google Closure Compiler. When I open the Developer Tools in Google Chrome, both the source map and the mapped files all load appropriately. A problem I'm having is that…
25
votes
1 answer

Why does Google's Closure Compiler leave a few unnecessary spaces or line breaks?

I've noticed that every time I use Google's Closure Compiler Service, it leaves a few unnecessary spaces in the compiled code presented on the right-hand side of the page. These correspond to line breaks in the hosted version of the compiled…
Bungle
  • 19,392
  • 24
  • 79
  • 106
24
votes
1 answer

Using the --module option in Closure Compiler to create multiple output files

I'm creating a fairly large library of JavaScript, using Closure Compiler for both its wonderful compression as well as the type-checking and warning systems. I want to create multiple output files though, because the files are loaded asynchronously…
Fortes
  • 1,436
  • 2
  • 12
  • 14
22
votes
2 answers

How do I split my javascript into modules using Google's Closure Compiler?

I want to use the google closure compiler on the javascript source we're using. In development mode we tend to break functionality to lots of files but for production would like to have them combined into modules. When calling the compiler I can…
Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
21
votes
1 answer

How to annotate anonymous object with optional property in JSDoc

I have a JavaScript class that takes one argument of type Object with defined set of properties and the Closure Compiler is happy when I annotate it like: @constructor @param {{ subview:BaseView, el:(jQuery|Element), title:String }} options var…
Pawel Dobierski
  • 407
  • 1
  • 4
  • 8
20
votes
1 answer

TypeScript performance (asm.js, closure compiler) and overhead

I'm looking into using TypeScript combined with a client-side MVC (most likely Backbone.js + Marionette.js or Ember.js) for future projects and therefor have a few questions related to performance and optimisation : How does TypeScript output…
m_vdbeek
  • 3,704
  • 7
  • 46
  • 77
20
votes
3 answers

Why does Closure Compiler insist on adding more bytes?

If I give Closure Compiler something like this: window.array = '0123456789'.split(''); It "compiles" it to this: window.array="0,1,2,3,4,5,6,7,8,9".split(","); Now as you can tell, that's bigger. Is there any reason why Closure Compiler is doing…
qwertymk
  • 34,200
  • 28
  • 121
  • 184
19
votes
3 answers

What is the current state of JavaScript static type checking?

I know that the Google Closure Compiler does type checking—but are there any alternatives, preferably that aren't so tightly coupled with a library and optimizer? If not, is there any way to have the Google Closure Compiler only do static…
Aaron Yodaiken
  • 19,163
  • 32
  • 103
  • 184
19
votes
1 answer

How can I set the language_in option for the Closure compiler?

I need to set the language_in option on the Closure compiler to prevent the IE8 parse error: ERROR - Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set…
Elisabeth
  • 2,972
  • 6
  • 35
  • 39
18
votes
3 answers

Closure Compiler Warning `dangerous use of the global this object`?

Dear folks, Closure Compiler gives this warnings in Advanced Mode, underlining {this. JSC_USED_GLOBAL_THIS: dangerous use of the global this object at line 200 character 33 hovers[i4].onfocus = function() {this.className +=…
Sam
  • 15,254
  • 25
  • 90
  • 145
17
votes
4 answers

JavaScript - package is a reserved keyword

I am trying to minify a third-party JavaScript library using Google Closure Compiler, but it errors out at below line: inBlock.package = package = name The error is ERROR - Parse error. missing name after . operator** name above is a local…
iwan
  • 7,269
  • 18
  • 48
  • 66
17
votes
5 answers

Integrate Google closure compiler with Eclipse IDE?

Does anybody know how to integrate Google closure compiler with Eclipse IDE? The thing I was trying to do is to configure Google closure compiler as a external tool for Eclipse IDE. Then I would be able to run closure compiler within IDE and minify…
Borivojević
  • 368
  • 2
  • 5
  • 12
17
votes
1 answer

What's the correct casing to use for jsDoc comments?

I've recently started using jsdoc comments for documenting our javascript code, however I'm finding conflicting examples of the usage of the @param tag. See https://code.google.com/p/jsdoc-toolkit/wiki/TagParam (PascalCase) and…
magritte
  • 7,396
  • 10
  • 59
  • 79
16
votes
6 answers

Prevent Google Closure Compiler from renaming settings objects

I'm trying to get the Google Closure Compiler to not rename objects when passed as settings or data to a function. By looking at the annotations present in jQuery, I thought this would work: /** @param {Object.} data */ window.hello =…
John Leidegren
  • 59,920
  • 20
  • 131
  • 152
1
2
3
78 79