开发者

is jQuery 1.4.2 compatible with Closure Compiler?

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://a开发者_如何学Gojax.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.


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).


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜