jQuery compiled with Google Closure Compiler

2019-01-06 15:11发布

Has anyone compiled jQuery against Google's newly-released Closure compiler?

There has been reported huge savings in code size. I'm curious what the benefit is if jQuery was compiled with it.

10条回答
别忘想泡老子
2楼-- · 2019-01-06 15:40

Doesn't Closure just minimize and renames vars? jQuery already has a .min version. Minifying with closure again will probably be minimally helpful and potentially dangerous.

Edit: I just did it.

Compilation was a success!

Original Size:  55.91KB (19.28KB gzipped)
Compiled Size:  54.05KB (18.28KB gzipped)
Saved 3.34% off the original size (5.18% off the gzipped size)

This is on top of the already mined version. There's a demo here: http://closure-compiler.appspot.com/home

查看更多
冷血范
3楼-- · 2019-01-06 15:49

I tried with their online compiler, it works well.

查看更多
虎瘦雄心在
4楼-- · 2019-01-06 15:50

Out of curiosity, I put together a SlickSpeed test of the latest Prototype and jQuery libs, shrunk with YUI and Closure. You can run the tests here.

As others have noted, compiling with ADVANCED_OPT does not work but if someone wants to do the work, I'll be happy to add the results to the SlickSpeed test.

查看更多
霸刀☆藐视天下
5楼-- · 2019-01-06 15:52

The closure compiler eliminates any code that you don't actually use. The typical web page will only use a small fraction of jQuery functions, so the most benefit will come from compiling your code together with the full version of jQuery.

查看更多
登录 后发表回答