使用带有闭包编译器的 jQueryUI
在使用闭包编译器进行缩小后,我无法让使用 jQuery UI 的 js 应用程序正常工作。
我做了什么:
- 转到 此处 并加载 jqueryui js 文件
- 要求 extern jQuery.ui
- 复制结果到一个文件并将其用作外部文件
但是应用程序崩溃了。对话框不再正确显示。爆炸效果无法正常工作,并且创建了多个对话框。有趣的是,自从创建了对话框之后,jQuery UI 本身就可以正常工作了。只是该应用程序行为不当。
我错过了什么吗?
I am having trouble getting a js app that uses jQuery UI to work after minifying using the closure compiler.
What I did:
- Go here and load up the jqueryui js file
- Asked to extern jQuery.ui
- Copied the result to a file and used it as an extern file
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.
Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
链接的外部提取器似乎无法从 jQuery 样式文件中提取外部。这很可能是因为 jQuery 使用“extend”方法来分配对象,并且该工具无法识别这些属性也需要扩展。
为了解决这个问题,您需要将扩展调用分解为直接赋值:
会变成
另外,在处理 jQuery 和使用高级优化时,应完全避免“$”别名。
这只是使用闭包编译器高级优化来编译 jQuery 代码具有挑战性的几个原因之一。
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:
Would become
Also, when dealing with jQuery and using advanced optimizations, the "$" alias should be avoided completely.
This is just one of several reasons why compiling jQuery code with Closure-compiler advanced optimizations is challenging.