My programming style always errs on the side of readability. A good algorithm and optimiser goes a long way to making pretty code run like tightly optimised assembler.
But does that apply to JavaScript?
This may sound like silly question. JavaScript is interpreted, not compiled, but the question is begged - what is the performance hit of all the nifty little JavaScript tricks we have developed over the years?
Does it matter if you go
if(condition)x++;
vs
if (condition)
{
x++;
}
Do comments slow down the code?
Is the length of function names a consideration?
What is the overhead of X.Y.Z style namespacing?
How about the "prototype" object and the call and apply functions?
Over the next week I'm going to be building some tests and publishing some results. I'm in the middle of a large JavaScript project and I've decided to work out if I'm committing any cardinal sins before I reach the point of no return.
The tests below were run under IE6 on an AMD1.4GHz with 1G RAM, Windows XP
BaseLine Test
In this test 200000 iterations of the main function are performed.
From the results below we seem to have a good baseline of ~ 250.

Varying Length Of Function Name
This tests a simple root level non anonymous function call.
eg.
function FFFFFF()
{
x = 1;
y = 2;
}
The function name is increased in length for each test (listed on X axis)
In this test 200000 iterations of the main function are performed
The length of the function name varies from 1 to 150 in increments of 10 characters.
From the results below you can see that there is some degradation, but its not a harsh curve. ~ 1% performance hit per 8 characters in the function name.

This second graph shows a more normal range of use for function names.
In this test 500000 itterations of the main function are performed. The length of the function name varies from 1 to 32 in increments of 2 characters.
The 1% performance drop per 8 characters is still observed.

This third graph in the series tests the function length to an extreme where you can see the scaling curve clearly. In this test 200000 itterations of the main function are performed. The length of the function name varies from 1 to 15000 in increments of 1000 characters.

Its pretty clear that in JavaScript the length of the function name matters. In compiled languages, every function call is compiled down to a memory address. In interpreted systems the function name is important. So if you have lots of long and descriptive function names, you are probably taking a performance hit of a few percent, which makes for a hard decision or readability over ultimate performance. For me, 1% is worth it if my function names can be easy to read and bear some resemblance to the actions they perform.
Now this may seem rather obvious, and to me these results are not unexpected, but you never know for sure till you really measure it.
More JavaScript drag racing tomorrow night :)