Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery compiled with Google Closure Compiler

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.

like image 488
Ted Avatar asked Nov 07 '09 03:11

Ted


3 Answers

John Resig reported a bug on recursive functions when he attempted to compile a nightly of jQuery 1.4, so there are a few kinks to be worked out. I wouldn't use a jQuery compiled with Closure Compiler without making sure it passes the jQuery testbed.

http://code.google.com/p/closure-compiler/issues/detail?id=1&can=1#c2

like image 192
Nosredna Avatar answered Nov 11 '22 20:11

Nosredna


I tried with jQuery jQuery 1.3.2

jQuery-1.3.2.min.js     57254 Bytes
jQuery closure compiler 49730 Bytes
-----------------------------------
Reduced by               7524 Bytes
Saved 13.31% off the original size
Saved 10.87% off the gzipped size

Gain of ~7KB

But it also reports 15 Warnings and I didn't test if it still works

like image 38
jitter Avatar answered Nov 11 '22 20:11

jitter


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.

like image 7
Steve Hanov Avatar answered Nov 11 '22 22:11

Steve Hanov