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

How do you use Google Compiler inside a browser, without requesting a service?

Is that possible already? Or is there an alternative for it? This is for an online IDE for a language that compiles to JavaScript. It would be nice if I could use the Closure Compiler as a last optimization step for my generated code, as I've got…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
0
votes
2 answers

How do I use google closure compiler to make a gigantic javascript file more efficient and maintainable?

I have a javascript file that is about 5000 lines long and may grow bigger in the future. I have been going through it by myself to try to figure out how to break it up and make it more modular / object oriented. however, I would really…
user1068636
  • 1,871
  • 7
  • 33
  • 57
0
votes
1 answer

Minify JavaScript code containing Jinja2 expressions with the Closure Compiler

I pass a JSON-encoded dictionary from Python 3 to Jinja2 template and assign it to a JavaScript variable. My template is as follows This works as…
vaultah
  • 44,105
  • 12
  • 114
  • 143
0
votes
1 answer

How to export public class methods in Closure Compiler in ADVANCED_OPTIMIZATIONS?

I'm using JavaScript inheritance inspired by John Resig and my library code looks like the following: var Person = Class.extend({ /** @private */ _dancing: null, /** @private */ _init: function(isDancing){ this._dancing = isDancing; …
Erik
  • 14,060
  • 49
  • 132
  • 218
0
votes
1 answer

Google Closure Compiler SourceMap with multiple files

How can I instruct google closure compiler to create a map file for my minified files that are in different folders preserving the right relative paths. I cannot even specify a sourceRoot as option in sourcemap generation I have a javascript file in…
0
votes
1 answer

Check Box using Google Closure

I retrieve a list of users from database and display it in a JSP. Each user has a status(Active or Inactive) associated with them and the status can be updated based on check-box selection on click of either activate or deactivate user. How do we…
0
votes
1 answer

Google closure compiler is replacing the jQuery word 'special'

I'm using Google's closure compiler (with ADVANCED_OPTIMIZATIONS) and when I run the minified version of my site I get this error in Firebug... TypeError: a.event.Yd is undefined This is coming from jquery.mousewheel.js It looks like this…
spiderplant0
  • 3,872
  • 12
  • 52
  • 91
0
votes
1 answer

Closure compiler removes more than what I want to remove

I've followed the advice from this other SO thread to remove console.log() statements from my code. Unfortunately, now Closure compiler is removing my entire code and not just the console.log() statements. Might someone explain this? I'm at a…
0
votes
1 answer

Activate a combobox from a checkbox using google closure

I have a set of check boxes with Id's user1,user2 and so on and also set of combo boxes with Id's usersel1,usersel2 and so on in a dialog. When a check box is checked (say suppose with Id user1) then corresponding combo box must be activated(i.e…
0
votes
1 answer

Minimize and protect function names inside objects or in the global scope

I have tried to minimize my javascript files using YUI compressor, but to no end, I cannot get the names of functions inside objects to minimize. I have tried to minimize function names in the global scope, but have come to understand this is not…
wayofthefuture
  • 8,339
  • 7
  • 36
  • 53
0
votes
1 answer

navigator.useragent reference lost in closure compiled js

I was using a simple regex test like is_safari_or_uiwebview = /(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent); in my js. After compile it with Closure compiler (advanced optimization) it's not working anymore. It still give me the…
Ruben Trancoso
  • 1,444
  • 5
  • 27
  • 55
0
votes
1 answer

closure compiler and Prototype.js: dangerous use of this

I wrote some javascript code relying on Prototype.js. Prototype.js's way to define classes is the following: var Person = Class.create({ initialize: function(name) { this.name = name; }, say: function(message) { return this.name + ': '…
peoro
  • 25,562
  • 20
  • 98
  • 150
0
votes
1 answer

Closure: --namespace Foo does not include Foo.Bar, and related issues

I have a rather big library with a significant set of APIs that I need to expose. In fact, I'd like to expose the whole thing. There is a lot of namespacing going on, like: FooLibrary.Bar FooLibrary.Qux.Rumps FooLibrary.Qux.Scrooge .. Basically,…
miracle2k
  • 29,597
  • 21
  • 65
  • 64
0
votes
2 answers

Properly type instance variables with closure compiler

I cannot get to properly type the following piece of code: /** *…
Mad Echet
  • 3,723
  • 7
  • 28
  • 44
0
votes
1 answer

Run command from NetBeans

I have an HTML5 project in NetBeans using Google Closure Compiler. Is it possible to run the compile command directly from NetBeans? I tried to use a macro, but with no success.
v.dubr
  • 1