使用jQueryUI与关闭编译器 [英] using jQueryUI with closure compiler

查看:96
本文介绍了使用jQueryUI与关闭编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法获取使用jQuery UI在使用closure编译器进行缩小后工作的js应用程序。

I am having trouble getting a js app that uses jQuery UI to work after minifying using the closure compiler.

我做了什么:


  1. 前往这里载入jqueryui js文件

  2. 要求extern jQuery.ui

  3. 将结果复制到文件并将其用作extern文件

  1. Go here and load up the jqueryui js file
  2. Asked to extern jQuery.ui
  3. Copied the result to a file and used it as an extern file

但是应用程序崩溃了。对话框不再正确显示。爆炸效果无法正常工作,并且创建了几个对话框。有趣的是,jQuery UI本身在工作有点,因为对话框被创建。

The app broke, though. The dialogs do not show correctly anymore. The explosion effect doesn't work correctly, and there are several dialogs created. It is interesting that jQuery UI itself is working somewhat, since the dialogs were created. It is just that the app is misbehaving.

我错过了什么?

推荐答案

链接的externs提取器似乎不能从jQuery样式文件中提取externs。这很可能是因为jQuery使用extend方法来分配对象,并且该工具不能识别这些属性也需要被externed。

The linked externs extractor doesn't appear to be able to extract externs from jQuery style files. This is most likely because jQuery uses the "extend" method to assign objects and that tool doesn't recognize that these properties need to be externed as well.

问题,您需要将扩展​​调用解析为直接赋值:

To address the issue, you would need to unravel the extend calls into direct assignments:

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

将成为

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

此外,当处理jQuery和使用高级优化时,应该完全避免$别名。

Also, when dealing with jQuery and using advanced optimizations, the "$" alias should be avoided completely.

这只是使用Closure-compiler高级优化编译jQuery代码具有挑战性的几个原因之一。

This is just one of several reasons why compiling jQuery code with Closure-compiler advanced optimizations is challenging.

这篇关于使用jQueryUI与关闭编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆