google-closure-compiler

Is it possible to use Closure Compiler ADVANCED_OPTIMIZATIONS with jQuery?

懵懂的女人 提交于 2019-11-28 19:58:09
I keep getting errors that the function (renamed) does not exist for the given object. Is there a release or setting or something to make it work? You have to declare jQuery as an extern to the compiler ...however I'm not sure if anyone's made one, there was an extern file for 1.3.2 , but I haven't seen any 1.4+ versions. Edit: this issue thread here has the community building a 1.4 version . You must use an externs file for jQuery when using Closure Compiler Advanced Mode with jQuery. Extern file will tell compiler these are reserved methods and accept these argument and argument data types

Use Closure Compiler Command Line Minify and Replace Original File

时光毁灭记忆、已成空白 提交于 2019-11-28 09:45:07
问题 I tried java -jar compiler.jar --js jj.js --js_output_file jj.js The output file size is 0. If I do not want to do a renaming from .min.js to .js, what should I do? 回答1: The compiler doesn't not support this. I believe the next release will actually fail before overwriting the file. 回答2: It isn't possible - for safety's sake although the following bash script achieves what you want to: #!/bin/sh for js in $(find ./public_html -name *.js) do java -jar compiler.jar --js $js --js_output_file $js

Javascript minification of comparison statements

对着背影说爱祢 提交于 2019-11-28 08:29:02
问题 I was looking over one of the minified js files generated by closure. I found that wherever I'm checking for equality between a variable and string like, a == "13" || a == "40" closure replaces it with "13" == a || "40" == a Why is this modification done? Is there some performance advantage here? 回答1: [UPDATE: See @John's answer, it makes more sense as to why a js minifier would do this, and should be the accepted answer] As a general concept, this is to avoid programmer error. If you were

Closure Compiler options

◇◆丶佛笑我妖孽 提交于 2019-11-28 05:36:47
问题 I want to use Closure Compiler to minify/compress JS code. the problem is that it doesn't minify as well as I expect it to. consider the code below. when I pass the string var func = function ( someArgument ) { alert ( someArgument ); return someArgument; } I expect the minified code to rename "someArgument" to something much shorter, like "a". is that the way it is or am I doing something wrong? TIA public static void Compress( String src ) { ByteArrayOutputStream err = new

Internet Explorer, Closure Compiler and Trailing Commas

僤鯓⒐⒋嵵緔 提交于 2019-11-28 04:34:46
问题 I'm using html5boilerplate build script and when minifying the scripts (which uses Google Closure Compiler) I'm getting this error -js.all.minify: [echo] Minifying scripts [copy] Copying 3 files to /Users/Username/Desktop/Web/intermediate/js [apply] /Users/Juan/Desktop/Web/js/plugins.js:117: ERROR - Parse error. Internet Explorer has a non-standard intepretation of trailing commas. Arrays will have the wrong length and objects will not parse at all. [apply] }, { duration: 727 }) [apply] ^ But

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

*爱你&永不变心* 提交于 2019-11-28 04:33:01
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 (and some files are only loaded on-demand). Poking around the source code, I've found the --module flag, as well as some related flags. The source code says the following about the option: A javascript module specification. The format is <name>:<num-js-files>[:[<dep>,...][:]]] . Module names must be unique. Each dep is the name of a module that

Compress all file .js with Google Closure Compiler Application in one File

你离开我真会死。 提交于 2019-11-27 21:21:38
问题 I would like to Compress all my file .js in a same directory in one file with Google Closure Compiler in a command line. For one file it's : java -jar compiler.jar --js test.js --js_output_file final.js But I didn't find in the doc how put my other file at the end of final.js without write over the last compress file ? I would like something like that : java -jar compiler.jar --js --option *.js --js_output_file final.js It's possible or must I do a programm who add all file in a file and

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

梦想的初衷 提交于 2019-11-27 21:20:40
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 += "Hovered";} JSC_USED_GLOBAL_THIS: dangerous use of the global this object at line 201 character 32 hovers[i4].onblur = function() {this.className = this.className.replace(/Hove... JSC_USED_GLOBAL_THIS: dangerous use of the global this object at line 201 character 49 hovers[i4].onblur = function() {this.className = this.className.replace(/Hove... JSC_USED_GLOBAL_THIS:

Getting closure-compiler and Node.js to play nice

﹥>﹥吖頭↗ 提交于 2019-11-27 20:05:30
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 require("./MyLib.js") , that line is put directly into the output, but it doesn't make any sense in that context. I see a few options: Code the entire application as a single file. This solves the problem by avoiding it, but is bad for maintenance. Assume that all files will be concatenated before execution. Again this avoids the problem, but makes it harder to

How to document a string type in jsdoc with limited possible values

流过昼夜 提交于 2019-11-27 18:55:29
I am having a function that accepts one string parameter. This parameter can have only one of a few defined possible values. What is the best way to document the same? Should shapeType be defined as enum or TypeDef or something else? Shape.prototype.create = function (shapeType) { // shapeType can be "rect", "circle" or "ellipse"... this.type = shapeType; }; Shape.prototype.getType = function (shapeType) { // shapeType can be "rect", "circle" or "ellipse"... return this.type; }; The second part of the problem is that the possible values of shapeType is not known in the file that defines