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
0
votes
1 answer

Closure compiler and PowerShell - How to "mute" warnings in console?

I'm trying to run the Closure Compiler from inside PowerShell: & $javaPath -jar $closurePath --js $jsCombinedPath --js_output_file $jsMinifiedPath It writes the minified file to $jsMinifiedPath and outputs that in console. If there are warnings…
Sheshbabu
  • 248
  • 2
  • 6
0
votes
1 answer

Closure Compiler is outputting a zero byte file with a Makefile

I made some modifications to SVG Edit which contains a make file. When I compile the source with a freshly cloned repo it compiles successfully, but when I do it on my local repo it seems to comply successfully but it results in a…
methodofaction
  • 70,885
  • 21
  • 151
  • 164
0
votes
1 answer

Translating VJET type annotations into Closure type annotations

EBay's VJET and Google's Closure Compiler both use type annotations in Javascript comments. Why have they chosen incompatible syntaxes? VJET function add(a, b) { //< Number add(Number, Number) return a + b ; } Google Closure /** * Queries a…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
0
votes
2 answers

Using 3rd party libraries with requirejs

Hi I trying to organize my code by using requirejs, but I need to use a library that uses google-closure-compiler, the library is box2djs and you can get it from https://github.com/leonidax/pl.git I found that the code calls functions such as…
Leonox
  • 75
  • 7
0
votes
4 answers

Closure compiler warning on for loop

I'm using a somewhat unconventional for loop that works well for what I'm doing as paraphrased below (not bothering to show variable declarations): if (arr && arr.length > 0) { for (i = arr.length; i--; i) { element = arr.pop(); …
Shane
  • 4,921
  • 5
  • 37
  • 53
0
votes
1 answer

Access source map for debugging Closure Compiler?

I am in the process of ironing out my codebase so it can compile with ADVANCED_OPTIMIZATIONS on google's closure compiler. After properly setting up the debugging environment required for this task (source map file, chrome, wrapping the compiled js…
thanpolas
  • 848
  • 1
  • 8
  • 20
0
votes
1 answer

using the Advanced Compilation in google closure compiler

I am new in google closure compiler,and after read the documents in the closure tools site,I create a js and make the test. However I found that even I use the Advanced Compilation level,the compiled codes are still easy to decompilated. For…
hguser
  • 35,079
  • 54
  • 159
  • 293
0
votes
1 answer

google closure compiler and history API

I have this code that I'm putting through the GCC in advanced compilation mode: window.addEventListener('popstate', function (event) { .... } I get this message: JSC_WRONG_ARGUMENT_COUNT: Function Window.prototype.addEventListener: called with 2…
frenchie
  • 51,731
  • 109
  • 304
  • 510
0
votes
3 answers

Getting rid of eval

I have a name of a method as a string in javascript variable and I would like to get a result of its call to variable: var myMethod = "methodToBeCalled"; var result; eval("result = "+myMethod+"();") This works and there are no problems. But this…
Vojtěch
  • 11,312
  • 31
  • 103
  • 173
0
votes
1 answer

Google Closure dividing code into compilation units

My JavaScript library is getting fairly large and slow to compile with Closure. I'd like to create a makefile that compiles only changed modules. However I'd still like to use ADVANCED_OPTIMIZATIONS to rename module contents for size and security…
jjrv
  • 4,211
  • 2
  • 40
  • 54
0
votes
1 answer

Javascript - Google closure annotation - Setting a type to anonymous functions

I am trying to annotate my Javascript properly in order to avoid Google Closure messing up with my variables. I am wondering if it is possible to strongly type an anonymous function to make sure the parameters of the function (which are externs in…
Mad Echet
  • 3,723
  • 7
  • 28
  • 44
0
votes
2 answers

Google Closure munging efficiency

I have a JavaScript file that I ran through the Google Closure compiler, and it munged the name on to za, which is obviously not more efficient from a length standpoint. Is there some reason it is, in fact, more efficient (possibly because of the…
exupero
  • 9,136
  • 8
  • 47
  • 63
0
votes
2 answers

ClojureScript extern 'on' event

I'm trying to use Twitter Bootstrap's modal dialog jQuery plugin with ClojureScript, which works fine without advanced optimizations, but when Google Closure munges method names, the on method becomes za. I've been trying to protect on from being…
exupero
  • 9,136
  • 8
  • 47
  • 63
-1
votes
1 answer

NullPointerException integrating Closure Compiler API in Java code

This application should receive some code from HttpServletRequest, compile it, and return a file with the compiled code. However, I get error below running the compiler.compile() call. No warnings or error messages were displayed at time of…
user411103
-1
votes
3 answers

Closure compiler treats definitions inside closures as redefinitions

I've been working with google closure, trying to get a large body of JavaScript to compile cleanly for minimization using the Google compiler. I came across a problem though: goog.provide('test'); goog.provide('test2'); /** * @constructor */ test…
hughdbrown
  • 47,733
  • 20
  • 85
  • 108