Is it possible to use the closure compiler to remove unused parts of jQuery?
I have a script which only uses jQuery's networking (json) functions, and I'd like a minified script which removes everything else.
I've tried invoking it with:
java -jar compiler.jar --compilation_level=ADVANCED_OPTIMIZATIONS --js=jquery-latest.js --js=my_script.js --js_output_file=out.js
But I end up with a file no smaller than the regular minified jQuery source.
Edit: I should mention the reason behind this. This script is going to be included in 3rd party websites, and it requires a later version of jQuery (1.5 or 1.6). I thought the easiest way to handle this was to bundle the latest version inside the script (only available to my script, not touching window.jQuery), removing unused parts to reduce size. That way if they already had an older version of jQuery, it wouldn't interfere.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…