jQuery 1.4.2 与 Closure 编译器兼容吗?
根据官方发布声明1.4版本已经重新发布-编写为使用 Closure Compiler 进行压缩,但是当我使用 closure 编译器 的在线版本时,我得到 130警告。
这是我使用的代码。
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// @code_url http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js
// ==/ClosureCompiler==
据我所知,如果您将库也包含在代码中,您将获得闭包编译器的真正好处,因此它会删除未使用的函数。然而我的测试表明,除了压缩库本身之外,我无法做任何进一步的事情。
我做错了什么?任何形式的见解将不胜感激。
According to the official release statement version 1.4 has been re-written to be compressed with Closure Compiler yet when I use the online version of closure compiler I get 130 warnings.
This is the code I use.
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// @code_url http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js
// ==/ClosureCompiler==
And as far as I know you get the real benefit of Closure Compiler if you include the library with your code also, so it removes the unused functions. Yet my testings show that I can't get any further than compressing the library itself..
What am I doing wrong? Any kind of insight will be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jQuery 1.4 与闭包编译器兼容,但仅与
SIMPLE_OPTIMIZATIONS
设置兼容。 jQuery的官方缩小版本实际上是使用此设置编译的,并且这个文件大小减少 13%。引用 John Resig 的 此提交评论:jQuery 1.4 is compatible with the Closure Compiler, but only with the
SIMPLE_OPTIMIZATIONS
setting. The official minified version of jQuery is actually compiled with this setting, and this reduces the file size by 13%. Quote from this commit comment by John Resig:jQuery 与高级模式下的 Closure Compiler 不兼容。我同意使其兼容是一件非常好的事情,因为它的方法链接语法很容易实现原型虚拟化,从而大大提高执行速度。
事实上,在流行的 JavaScript 库中(除了 Closure Library 之外),只有 Dojo Toolkit 与 Closure Advanced 模式兼容。
http://dojo-toolkit.33424 .n3.nabble.com/file/n2636749/Using_the_Dojo_Toolkit_with_the_Closure_Compiler.pdf?by-user=t
jQuery is not compatible (yet) with the Closure Compiler in advanced mode. I agree it would be a very good thing to make it compatible, because its method-chaining syntax lends very readily to prototype virtualization for much improved execution speed.
In fact, among the popular JavaScript libraries (other than Closure Library, that is), only the Dojo Toolkit is compatible with Closure Advanced mode.
http://dojo-toolkit.33424.n3.nabble.com/file/n2636749/Using_the_Dojo_Toolkit_with_the_Closure_Compiler.pdf?by-user=t