[thelist] JavaScript Speed: Tips Required

Danny Goodman dannyg at dannyg.com
Fri Sep 20 12:12:25 CDT 2002

Look for usage of the eval() function, which is inherently verrry slow, and
inside loops compounds the slowness. There is almost always a way to use
string identifiers with arrays/collections to obtain the object reference
for which the eval() function is probably being used.

I remember Brendan Eich telling me a long time ago that the 'with'
construction was also pokey. Can't say whether it has improved since then,
but it's one of those things that I simply avoid.

Avoid repeating lengthy static object references inside loops, because they
have to evaluate each time through the loop. It's more efficient to perform
the evaluation once outside of the loop (assigning the reference to a local
variable), and then use the variable inside the loop.

[DHTMLTDR2 Now Shipping]

> Can you guys give some tips about how to speed up a JavaScript chunk?

More information about the thelist mailing list