There is a discussion about JavaScript coding in my work group. Some people argues that we should use long-name for better readability; the others believes that short-name should be favored to same bits-on-wire.
Generally, it is about coding convention. One side believes that identifier such as "fAutoAdjustWidth" is OK, while others prefer to "fAtAjtW".
So, what's the better way? Should we sacrifice readability for performance or not?
Naming ConventionsAlways use the same naming convention for all your code. For example: Variable and function names written as camelCase. Global variables written in UPPERCASE (We don't, but it's quite common)
Giving them longer names would only cause more confusion. If a variable is used frequently but represents something more complex, then you have to give it a clear name so that the user doesn't have to relearn what it means every time they use it.
A function name is too long when it starts to either over-describe what it does, or when it hinders readability of the code. Well put. Keep the names clear and concise but still descriptive.
Make it readable, and if you feel that the resulting JS file is to big, use one of many JS compactors before deploying the production version, while maintaining development version with long names.
BTW. if your really worried about bandwidth, use mod_deflate.
If you're worried about bits on the wire, you could always run a minifier on your code. Then you could develop with long names, and you could release with a much smaller file that has equivalent functionality. The Yahoo YUI Compressor looks like it does whitespace compression and token compression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With