I just watched a short presentation by Douglas Crockford where he said that the benefits of optimizing JS were insignificant. His reasoning was that the DOM is so inefficient and spends so much time rendering layout, style, etc, that it negates the benefits of optimizing code. Is this true?
Have you heard the phrase about premature optimization being the root of all evil? Before optimizing, figure out where the slowdowns and bottlenecks are, so that your optimizations can then be effectively targeted at dealing with the actual problem that is being faced.
Where the optimised version is just as quick to write and just as easy to read as the unoptimised version then using the optimised version still makes sense.
Where the optimised version results in less typing and easier to read code then there is even less reason for using the alternative.
Often using a slightly better optimised version means that you are using code that is easier to read and maintain.
So for example I’d reference the first data row in a table using:
because it is shorter to type and easier to read and the fact that the shorter version is actually a more efficient way to do the access iin most modern browsers is an added benefit rather than a reason.