single function stops working after ADVANCED_OPTIMISATION
See original GitHub issueI tried optimize my simple code which uses jQuery. I included jQuery’s code and close it in one function with my code, to avoid any external dependencies.
Code works fine in SIMPLE_OPTIMISATION mode, and gives: ‘Uncaught TypeError: $ is not a function’ in ADVANCED_OPTIMISATION
(function(){
//jQuery without any modification included here. Omited.
/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
/*this line works in SIMPLE_OPTIMISATION mode, and gives:
'Uncaught TypeError: $ is not a function' in ADVANCED_OPTIMISATION */
$(window);
})()
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
2.7. Mathematical optimization: finding minima of functions
Many optimization methods rely on gradients of the objective function. If the gradient function is not given, they are computed numerically, which induces ......
Read more >5.8 Optimization Problems
Guideline for Solving Optimization Problems. · Identify what is to be maximized or minimized and what the constraints are. · Draw a diagram...
Read more >24 Improving performance | Advanced R - Hadley Wickham
After several hours work, I was able to isolate the minimal code shown above. This is a very useful technique. Most base R...
Read more >Optimize Options (Using the GNU Compiler Collection (GCC))
This is the default when not optimizing. Single functions can be exempted from inlining by marking them with the noinline attribute. -finline-small-functions.
Read more >Understanding the Restrictions Imposed by the Closure ...
All Compiler optimization levels remove comments, so code that relies on specially formatted comments does not work with the Compiler.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s likely that the jQuery code you included does not explicitly export the
$
symbol, so the compiler will remove it. AFAIK the jQuery code itself is not compatible with ADVANCED_OPTIMIZATION, so a better way would be compiling just your application with the jQuery externs file (https://github.com/google/closure-compiler/blob/master/contrib/externs/jquery-1.9.js), and then bundling it with a minified jQuery code. The externs file is namedjquery-1.9.js
but should work under 1.11 in most cases.Most random code are compatible with SIMPLE _OPTIMIZATIONS, making them compatible WITH ADVANCED is a non-goal for the compiler 😃