When I compile multiple time my JS, the output is smaller the second
time :
java -jar compiler.jar --js=jquery.js --js_output_file=jquery.min.js
java -jar compiler.jar --js=jquery.min.js --
js_output_file=jquery.min2.js
jquery.min2.js is smaller than jquery.min.js
After that, the code size does not decrease.
Couldn't Closure shrink it to min2 the first time ?
Is there a reason for that difference ?
Thank you
Thomas
PS : I tested with jquery 1.4 RC1 ( http://jquery14.com/pre-release-2/jquery-14rc1
)
One reason is that Closure Compiler assumes that your code uses dotted
properties when the name can safely be renamed, and quoted properties
when the name can't be renamed:
foo.propertyToRename = 1;
foo['propertyCannotBeRenamed'] = 2;
Closure Compiler also converts quoted property references to dotted
property references to save three bytes, so the output for the above
code would be:
foo.a = 1;
foo.propertyCannotBeRenamed = 2;
When you run it through the compiler again, Closure Compiler doesn't
realize that 'propertyCannotBeRenamed' is special, and assumes the
second is safe to rename:
foo.a = 1;
foo.b = 2;
Also, if Closure Compiler sees JSDoc comments with @license tags, it
assumes the text of that comment must appear in the final file. The
@license tag doesn't get included in the output, so if you re-
processed the file, the comment would be deleted.
Robert
i don't think that default mode does property renaming?
has anybody checked what the actual difference is between the two
files? does jquery.min.js have a @license tag in it?
Nick