I was looking over some of our JavaScript compression and noticed that no strings that aren’t object property names are minified into variables.
For example, let’s say I have these two pieces of code in my script:
alert("Wrong answer");
alert("Wrong answer buddy");
The minification we get from YUI and Closure, if I’m not mistaken, is:
alert("Wrong answer");alert("Wrong answer buddy");
I would think the resulting minification would look like this:
var a="Wrong answer";alert(a);alert(a+" buddy");
Do any minification tools do this? What’s stopping our tools from doing this?
gzip compression will reduce identical strings to a byte or two. Use that and it’s a non-issue. 🙂