google-closure-compiler

Any ideas on how to use Google Closure Compiler to combine multiple javascript files w/o any optimizations?

有些话、适合烂在心里 提交于 2019-12-04 01:30:35
问题 Any ideas on how to use Google Closure Compiler to combine multiple JavaScript files w/o any optimizations? Specifically, we want to use Closure to deploy two versions of our combined site JavaScript: release and debug. For release, we are using --compilation_level SIMPLE_OPTIMIZATIONS --manage_closure_dependencies which is working as intended. However, for debug, we would like our JavaScript to be combined intact/unmodified for easier debugging. It seems the minimum level of optimization is

How can I prevent the warning 'Property MyProp1 never defined on MyObject'?

戏子无情 提交于 2019-12-03 23:55:18
问题 I have some HTML that contains a JSON string. In the on DOM ready callback, I have something like this: MyObject = JSON.parse($('#TheJsonString').html()); Later in my code, I write something this: var SomeVar = MyObject.MyProp1; And then when I run the code through the Google closure compiler, I get the warning Property MyProp1 never defined on MyObject. How should the code be written so that it doesn't generate a warning? 回答1: The cleanest way to remove the warning is by defining the

What is the current state of JavaScript static type checking?

本秂侑毒 提交于 2019-12-03 22:34:04
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 analysis? (By static analysis here, I mean things like defining types for arguments and so on that I can run through something to give me warnings if I make a typo or pass the wrong type.) There's Doctor JS , which is a Mozilla project that primarily (as I understand it, at least) does type-checking for JS. Microsoft's AJAX Minifier is a little more relaxed

How does Google Closure Compiler handle quotes (string literals)?

 ̄綄美尐妖づ 提交于 2019-12-03 22:10:21
问题 The question 'How does Google Closure Compiler handle quotes (string literals)?' could also be re-phrased like: Why does Closure replace/swap single quotes with double quotes? How does Closure decide what quote- formatting/style to use? (How) can I change this (default) behavior? Note 1: this question is not about why Closure (or some other minifiers) have chosen to prefer double quotes (as is asked here and here). Note 2: this question is not about single vs double quote discussions, however

How to use Google Closure compiler

久未见 提交于 2019-12-03 17:15:16
I'm trying to migrate from the closurebuilder.py script to the Closure compiler because of this message: ../../closure-library/closure/bin/build/closurebuilder.py: Closure Compiler now natively understands and orders Closure dependencies and is prefererred over using this script for performing JavaScript compilation Since I'm using Google Closure Library and the OpenLayers 3 , how do I have to call the compiler (compiler.jar) to Build an myapp-deps.js dependency file Build an minified version myapp.js that includes only used OL3 and CL classes Build both with the usage of pre-calculated

How to document return in JavaScript

会有一股神秘感。 提交于 2019-12-03 16:27:26
问题 I'm writing my own library for the project at work for a browser application and I am having the same old problem deciding how to comment the code. I'm trying to follow the JsDoc syntax, but will probably continue the Google Closure Compiler way. I may end up using two @return and @returns tags in the documentation, just for portability sake (when I setup the auto-generation of the documentation). Now, the question, how do you document the return of a custom anonymous object from a function?

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

流过昼夜 提交于 2019-12-03 15:15:00
问题 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 the appropriate language_in option. I did find a post in the closure group relating to this, however, the option is set directly on the java compiler, rather than through one of the build scripts. I need to be able to set it on a build script. I'm

How to prevent Closure Compiler from renaming “true”, “false” and “null”

a 夏天 提交于 2019-12-03 14:12:50
Google Closure Compiler renames all "true", "false" and "null" occurences in code like; var s = true, x = null, V = false; and uses these shorthands instead; in conditions such as; if (someVariable == s) now; Google Analytics code defines it's own "s" variable; overriding the value "true"; and as you can see this causes a lot of problems. I don't want to change GA code; I just want Closure Compiler to quit renaming true etc. Externs do not work. Do you know any way to accomplish this? It turns out that one can prevent Google Closure Compiler from printing out global definitions (function and

google closure compiler and jquery

只谈情不闲聊 提交于 2019-12-03 12:11:29
问题 I copy-pasted my js code into the google compiler and when I copied it back into my application it didn't work. I realized that my code needs jquery so I copied the jquery code and my code into the google compiler, hoping it would easily solve the problem, but it doesn't work either. In chrome, the code bugs on the line $(document).K(function () { which is the document ready function. The error is Uncaught TypeError: Object [object Object] has no method 'K' What do I need to do to make it

How to use Google's Closure to compile JavaScript

扶醉桌前 提交于 2019-12-03 11:54:15
问题 Google just released Closure, which is a compiler to minify JavaScript. On the product site, it says "The Closure Compiler has also been integrated with Page Speed". How do I use Page Speed to compile my web pages JavaScript with Closure? (Or, is there a web site that I can simply paste in my JavaScript to have closure minify it? 回答1: For a single file it's simple java -jar $path_to_jar/compiler.jar --js input_file.js \ --js_output_file output_file.js For a multi-file project you can use