[thelist] JavaScript Speed: Tips Required

Richard Bennett richard.bennett at skynet.be
Fri Sep 20 05:25:01 CDT 2002

<----- Original Message -----
<From: "Syed Zeeshan Haider" <szh at softhome.net>
<That same script (which was previously under consideration) is too slow. It
<many "for" and "while" loops.
<Can you guys give some tips about how to speed up a JavaScript chunk?

Often when you have a long for loop, the browser will freeze while it is
executing, and the user thinks something has gone wrong.

One way around this is to break your for loops into smaller loops, which are
then called by a setTimeout().
A setTimeout will allow the browser to update itself, allowing you to show a
progress-bar or something.

function firstPart(){
    status="loading 1 %"
    for(i in something1){
        do something;
function secondPart(){
    status="loading 2 %"
    for(i in something2){
        do something


More information about the thelist mailing list