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
2 answers

Closure Compiler (advanced mode) -- How to design classes?

I have a class that has roughly this structure: function MyClass() { // constructur stuff } MyClass.prototype.myFunc = function () { // example function }; MyClass.myStaticFunc = function () { // example static function }; I spent…
Ingo Bürk
  • 19,263
  • 6
  • 66
  • 100
0
votes
1 answer

closure compiler and closure inspector

I am reading an old book on google closure and it tells me about debugging code using closure inspector. The following page tells me that it's depreciated: https://developers.google.com/closure/compiler/docs/inspector It does not say what to use…
HMR
  • 37,593
  • 24
  • 91
  • 160
0
votes
2 answers

More Granular Closure Compiler Flags?

I am using closure compiler to minfiy and concatenate my scripts and I would like to use the ADVANCED_OPTIMIZATIONS flag to get even more minifying magic out of it. However some of the scripts I have create warnings when I use this flag and do not…
BillPull
  • 6,853
  • 15
  • 60
  • 99
0
votes
1 answer

Is it possible to compile WebDriverJS without minimizing the code by Google Closure Compiler?

I need to modify WebDriverJS for my purposes. The compiled source is giving me a hard time debugging, though. Describing function names and comments would help me out big time! So I was wondering whether it is possible to compile WebDriverJS without…
0
votes
2 answers

Export property of an object

How do I export the method of an object to call externally in the HTML page. The JavaScript code: my.namespace.FeedbackController = Class.create(); Object.extend(my.namespace.FeedbackController.prototype, { initialize:function(fid, fitem){ …
Chris
  • 816
  • 4
  • 11
  • 23
0
votes
3 answers

Closure compiler mixes variable names

I have a problem where the Closure Compiler renames a global variable something like x.sa.xa but in all function where that global variable is referenced the compiler renames it something else like H.sa.xa When I view the HTML page I get a…
Chris
  • 816
  • 4
  • 11
  • 23
0
votes
0 answers

Google Closure Compiler shell script in Mac OS

On my PC I'm using this bat script to compile my JavaScript project: https://github.com/ChristianDen/fx.js/blob/master/build/compile.bat And it works great! Now, I want to run that on Mac using Terminal. So far, I've renamed the script with an .sh…
ChrisRich
  • 8,300
  • 11
  • 48
  • 67
0
votes
1 answer

Is there a way to have closure compiler warn about passed variables (strong type) AND use jquery?

I have a simple example: var obj = { /** * @param {number} inp * @returns {number} returning number plus one */ func: function(inp) { return inp++; }, c: 'hello', q: null }; obj.func($(document)); // passing invalid…
HMR
  • 37,593
  • 24
  • 91
  • 160
0
votes
0 answers

gjslint not reporting any error on file without jsdoc whatsoever

I read somewhere that with jsdoc in your JavaScript and the google closure tool gjslint you can strongly type your javascript. It's not really strongly typed but the tool will report on uncommented variables and or parameters. Here is the test…
HMR
  • 37,593
  • 24
  • 91
  • 160
0
votes
3 answers

Disable creation of report.txt while using Google Closure Compiler with Grunt JS

To minify and obfuscate my JS code I'm trying to use Grunt's closure-compiler plugin. I'm perfectly happy with the result, but after running Grunt I get project.min.js.report.txt file in the output directory. I haven't found any options responsible…
gkond
  • 3,818
  • 2
  • 20
  • 27
0
votes
0 answers

Annotate parameter as function accepting several types as params for closure compiler

I want to annotate a parameter to a method call to be a function accepting two parameters, first being Error or null and second being an Object or Array of objects. However I seem to not be able to figure out the correct annotation - compiler always…
Peter StJ
  • 2,297
  • 3
  • 21
  • 29
0
votes
2 answers

Using function from minified .js (Google Closure) in Play 2.0

I wanted to use Google Closure Compiler to to minimize javascript, but in minimized version it renames function names. Is this the intended behavior? How to use this in that situation ? lib.js function myfun() { …
marioosh
  • 27,328
  • 49
  • 143
  • 192
0
votes
3 answers

Using Plovr to remove whitespace from simple javascript file without managing dependencies

I can't figure out how to get Plovr to just remove whitespace from a simple javascript file and not try to manage dependencies or scopes. (I don't want to use ADVANCED mode if I can help it because my needs for this file are extremely simple and I…
0
votes
1 answer

Tell the Closure Compiler not to rename any function

I want to compile part of my JS code which is based on Mootools library. I want all the variables be renamed but none of the function, the called and defined ones. Because most of the called one are from mootools and those defined are called from…
Ali
  • 21,572
  • 15
  • 83
  • 95
0
votes
1 answer

How do I use the Google Closure Compiler to build one file?

The question is a little more complicated than the title suggests, so allow me to elaborate. I have a project that is split into two repositories. The both use Google Closure for dependency management and compilation. I need to deliver a compiled…
ian
  • 168
  • 1
  • 1
  • 7