I’m trying to understand how all these tools work since, as far as I know, they change the name of variables to achieve a better compression.
Do they also change the name of properties of objects? I guess they would not, since otherwise anything using the object[property] notation, where property is computed dynamically, could fail. Is this right?
So, in this case, if everything is namespaced with only one global variable, there will be no gain in changing variable names. Is this right again?
Packer does a form of compression, replacing common words with shorter tokens. It doesn’t do renaming at all.
Tools like YUI Compressor change only local variables (and arguments), but you can store commonly-used objects in local variables to take advantage of the space considerations. (Also, it’s slightly faster to access local variables vs. crawling the scope chain up to the top level.)