google-closure-compiler
How to document a string type in jsdoc with limited possible values
As of late 2014 in jsdoc3 you have the possibility to write: /** * @param {(‘rect’|’circle’|’ellipse’)} shapeType – The allowed type of the shape */ Shape.prototype.getType = function (shapeType) { return this.type; }; Of course this will not be as reusable as a dedicated enum but in many cases a dummy enum is an overkill … Read more
Does it make sense to minify code used in NodeJS?
Minification can improve performance. Node’s V8 optimizing compiler inlines functions according to some heuristics. Minification influences these heuristics. This can cause inlining of previously not inlined functions. Since inlined functions generally perform faster, this can lead to performance improvements. ###Node 9.0+ / V8 6.2+ (Turbofan) – minor performance improvements If the function’s unoptimized bytecode size … Read more
How do I split my javascript into modules using Google’s Closure Compiler?
Closure-compiler’s ability to create multiple output files provides a powerful tool to separate input files into distinct output chunks. It is designed such that different chunks can be loaded at differing times depending on the features required. There are multiple compiler flags pertaining to chunks. Each use of the –chunk flag describes an output file … Read more
Partially skip sections with Google Closure Compiler
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 = {}; mynamespace.jsvar = “‘ . $var . ‘”;’; ?> And in my … Read more
jQuery compiled with Google Closure Compiler
John Resig reported a bug on recursive functions when he attempted to compile a nightly of jQuery 1.4, so there are a few kinks to be worked out. I wouldn’t use a jQuery compiled with Closure Compiler without making sure it passes the jQuery testbed. http://code.google.com/p/closure-compiler/issues/detail?id=1&can=1#c2
Exclude debug JavaScript code during minification
here’s the (ultimate) answer for closure compiler : /** @const */ var LOG = false; … LOG && log(‘hello world !’); // compiler will remove this line … this will even work with SIMPLE_OPTIMIZATIONS and no –define= is necessary !
difference between “void 0 ” and “undefined”
From MDN: The void operator evaluates the given expression and then returns undefined. This operator allows inserting expressions that produce side effects into places where an expression that evaluates to undefined is desired. The void operator is often used merely to obtain the undefined primitive value, usually using “void(0)” (which is equivalent to “void 0“). … Read more