jQuery 1.4.2 与 Closure 编译器兼容吗?

发布于 2024-08-27 06:40:23 字数 620 浏览 4 评论 0原文

根据官方发布声明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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

差↓一点笑了 2024-09-03 06:40:23

jQuery 1.4 与闭包编译器兼容,但仅与 SIMPLE_OPTIMIZATIONS 设置兼容。 jQuery的官方缩小版本实际上是使用此设置编译的,并且这个文件大小减少 13%。引用 John Resig 的 此提交评论

从使用 YUI Compressor 切换到使用 Google 编译器。缩小和
Gzip 压缩后的文件大小从 26,169 字节减少到 22,839 字节(减少了 13%)
文件大小)。

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:

Switched from using YUI Compressor to Google Compiler. Minified and
Gzipped filesize reduced to 22,839 bytes from 26,169 bytes (13% decrease
in filesize).

他不在意 2024-09-03 06:40:23

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文