4 ms·
I'd take a guess that you need to write your JS with Closure in mind. I wonder how much jQuery code would be stripped out with the Closure compiler.
by chrisbroadfoot 15y ago
I'd take a guess that you need to write your JS with Closure in mind. I wonder how much jQuery code would be stripped out with the Closure compiler.
- epidemian 15y agoThat might be the case. This blog post [1] shows some examples of what the advance optimizations do and it seems that, while it'll shorten everithing up, things that are put in the global namespace (window) will not be stripped even when they aren't called. As jQuery adds the 'jQuery' and '$' variable to the global namespace and all it's functions are attached to that object, I would assume that the Closure compile connot remove any of them. Of course, this is all pure speculation, it'd be much better to test this out. [1]: http://www.bitstorm.org/weblog/2010-8/Introduction_to_the_Google_Closure_Compiler.html http://www.bitstorm.org/weblog/2010-8/Introduction_to_the_Go...
- chrisbroadfoot 15y agoClosure can definitely remove functions that are never called - but I wonder if its static analysis can figure out jQuery style code. My guess is that it'll do a decent job, but jQuery would need many changes to get it to compile.