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?
Asked
Active
Viewed 4,475 times
6
-
possible duplicate of [jQuery compiled with Google Closure Compiler](http://stackoverflow.com/questions/1691861/jquery-compiled-with-google-closure-compiler) – Chris Moschini Jun 20 '14 at 21:46
2 Answers
8
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 which IS compatible with ADAVANCED_OPTIMIZATIONS. It is available on my GitHub account.
A version of the jQuery 2.0.x branch that is compatible is under development, but not yet complete.

Chad Killingsworth
- 14,360
- 2
- 34
- 57
-
Thank you for your quick response Chad. We are still using jquery1.5.1 Do you think the extern files for previous versions are relaible? My main concern is I want to use GCC with Self-executed anonymous functions(SEAF) in JS. Does GCC work for SEAF's? If so can you please share a example that has self-executed anonymous function working with the compiled code? – user2109546 May 10 '13 at 12:51
-
The jQuery 1.5 externs are quite stable. The compiler handles immediately executed anonymous functions quite well. There are samples everywhere for this. The only trouble comes with shadowing namespaces `(function($){...})(jQuery)`. It's best to avoid that practice. Since this is a different topic, if you have more information around this I suggest posting a new question. – Chad Killingsworth May 10 '13 at 13:13
-
Thank for the explanation Chad. Can you share the link where I can get extern files for jquery-ui and jquery ui plugins? – user2109546 May 24 '13 at 18:53
-
3
-
1Has the externs file for jQuery 2.0.x branch been complete yet? I don't see it listed: https://github.com/iplabs/closure-compiler/tree/master/contrib/externs – Frank Hale Nov 27 '13 at 16:11
-
@FrankHale For posterity, it appears that version 1.9 supports from v1.9 to v2.1 (at least) https://github.com/google/closure-compiler/issues/970 – Ed J Jul 15 '16 at 07:42
1
Try adding this flag:
--process_jquery_primitives
https://code.google.com/p/closure-compiler/wiki/jQueryExpansions

f0ster
- 549
- 3
- 12