Using jQueryUI with a closure compiler

I'm having trouble getting a js application that uses the jQuery UI to work after minimization using the close compiler.

What I've done:

  • Go here and download the jqueryui js file
  • Query extern jQuery.ui
  • I copied the result to a file and used it as an external file

The application has broken. Dialogs are no longer displayed. The explosion effect does not work correctly and several dialog boxes are created. Interestingly, the jQuery user interface works somewhat since the dialogs were created. Just the application is behaving badly.

Did I miss something?

+4
source share
1 answer

The linked externs extractor does not seem to be able to extract externs from jQuery style files. This is most likely because jQuery uses the extend method to assign objects, and this tool does not recognize that these properties must also be externed.

To solve this problem, you need to unravel the extension calls into direct destinations:

jQuery.extend(jQuery.ui, { prop1: function() {}, prop2: function() {}); 

Would become

 jQuery.ui = jQuery.ui || {}; jQuery.ui.prop1 = function() {}; jQuery.ui.prop2 = function() {}; 

In addition, when working with jQuery and using advanced optimizations, you should completely eliminate the $ alias.

This is just one of the reasons why the complexity of compiling jQuery code with the advanced optimization of the Closure compiler is difficult.

+1
source

All Articles