Alex Rivera | Logout

How to stop intense Javascript loop from freezing the browser

Asked 2009-04-03T17:43:40.673
62

I'm using Javascript to parse an XML file with about 3,500 elements. I'm using a jQuery "each" function, but I could use any form of loop.
The problem is that the browser freezes for a few seconds while the loop executes. What's the best way to stop freezing the browser without slowing the code down too much?

$(xmlDoc).find("Object").each(function() {
    //Processing here
});
Edit
Report

1 Answer

3

you can setTimeout() with duration of ZERO and it will yield as desired

answered 2009-04-03T20:27:58.953

Your Answer