On May 29, 4:06 am, Tom Potts <madtom1...@yahoo.comwrote:
Cool.
I was just wondering if javascript would run a lot faster with shorter
variable names - less time to lookup?
Shorter variable names will reduce download times. However if you gzip
files before serving then the reduction will be minimal because gzip
capitalizes on repeated patterns in a file. The main percentage gain
of minification is removing the comments. If the file will _not_ be
gzipped then there is also a big gain by removing whitespace. If the
file will be gzipped then the gzip handles the whitespace quite well
because it is a repeated pattern.
Shorter variable names won't make the JavaScript run faster because
the JavaScript is compiled when it arrives at the browser.
If this is the case then does anyone know of a minifier that would be
able to shrink the variable names to something smaller?
There are programs that reduce variable name size. This is usually
called obfuscation because it makes the code more difficult to read.
It is more difficult to write an obfuscator and so introducing bugs in
your working code is more likely. Also an obfuscator won't hide the
intention of your code from a reader who really wants to understand
it. Words like function, for, this, document, window, etc are not
normally obfuscated. A major effort would need to be made to obfuscate
these words and the code to unubfuscate it would also be in the
JavaScript (unless flash was used to unobfuscate, I suppose, but even
then the reader could use the flash to unobfusicate the code (it is
futile)).
Peter