google-closure-compiler

Is it possible to use Closure Compiler ADVANCED_OPTIMIZATIONS with jQuery?

こ雲淡風輕ζ 提交于 2019-11-27 12:35:57
问题 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? 回答1: 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. 回答2: You must use an externs file for jQuery when using Closure Compiler Advanced Mode with jQuery.

Does it make sense to minify code used in NodeJS?

浪尽此生 提交于 2019-11-27 11:53:29
I was wondering, since Clojure Compiler and UglifyJS not only optimize code for size but also for performance (although I think size is the main priority), would my node.js app run faster if it was minified ? I know it may depend from app, but I'm asking this in general. In node, the main processing cost is I/O operations, not the actual JavaScript itself. So for example: fs.readFile(myFile, function (err, data) { processTheFile(data); }); Here, the gap between calling readFile and the callback being fired will be several times longer than the length of time the callback takes. (If it's the

Running a command in a Grunt Task

两盒软妹~` 提交于 2019-11-27 10:42:41
I'm using Grunt (task-based command line build tool for JavaScript projects) in my project. I've created a custom tag and I am wondering if it is possible to run a command into it. To clarify, I'm trying to use Closure Templates and "the task" should call the jar file to pre-compile the Soy file to a javascript file. I'm running this jar from command line, but I want to set it as a task. Alternatively you could load in grunt plugins to help this: grunt-shell example: shell: { make_directory: { command: 'mkdir test' } } or grunt-exec example: exec: { remove_logs: { command: 'rm -f *.log' },

How do I split my javascript into modules using Google's Closure Compiler?

ぃ、小莉子 提交于 2019-11-27 08:04:43
I want to use the google closure compiler on the javascript source we're using. In development mode we tend to break functionality to lots of files but for production would like to have them combined into modules. When calling the compiler I can give it a list of files to include for compilation, but the output of that shows that the compiler did not save the order of the files list. I searched about it and found that I can use goog.provide/good.require in order to control the dependencies between the different js files. The problem with that is that it adds code to my js which I just don't

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

旧时模样 提交于 2019-11-27 05:22:28
问题 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>:

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

不羁岁月 提交于 2019-11-27 04:18:22
问题 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

How to make Jquery work with google closure compiler

旧巷老猫 提交于 2019-11-27 02:31:28
问题 I have been going through all the posts related to GCC with JQuery but unable to find the solution. Is JQuery still not compatible to work with GCC? If not can you please refer to the appropriate link or provide an example? 回答1: The main distribution of jQuery is not compatible with Closure-compiler ADVANCED_OPTIMIZATIONS. To use the main build of jQuery you must reference the appropriate jQuery extern file in the Closure-compiler contrib folder. I have an experimental jQuery 1.9.1 build

WIKI: How to use Lime (how to use closure-compiler with 3rd party (closure) libraries)

百般思念 提交于 2019-11-27 02:27:56
问题 The following post inspired me to have a look at limeJS, as a side project I'm working on and off an a Yatzee game (mostly off) and thought that might be a nice library to use. As a beginner in google-closure I had some difficulties running uncompiled code and getting code compiled, mostly due to not knowing what the options and commands are and because of dependencies. For other beginners with google-closuse I have written this tutorial. Note that jQuery can be used by your closure compiled

Partially skip sections with Google Closure Compiler

半世苍凉 提交于 2019-11-27 02:17:28
I'm generating a javascript on the server like and would like to run Google Clousure Compiler to be ran on the php source code of the script. var jsvar = <?=$var ? true : false ?>; Just wandering if there is any way in telling the compiler to skip optimazation of ? Like a regexp skip: /<\?=.*?\?>/ Best regards, Niclas I have found that my code is much easier to maintain when I separate my client-side JavaScript from my server-side logic. Now I write my scripts such that my server-side processing emits initialization variables. Example - Server Side: <?php echo 'var mynamespace = {};

Prevent Google Closure Compiler from renaming settings objects

泄露秘密 提交于 2019-11-26 23:20:54
问题 I'm trying to get the Google Closure Compiler to not rename objects when passed as settings or data to a function. By looking at the annotations present in jQuery, I thought this would work: /** @param {Object.<string,*>} data */ window.hello = function(data) { alert(data.hello); }; hello({ hello: "World" }); However, it ends up like this: window.a = function(b) { alert(b.a) }; hello({a:"World"}); The ajax function found here has this annotation and it appears to work. So, why won't this? If