Is there a good way of performing a long-running operation in javascript?
For example, I have a function which may take 2 minutes to run.
How do we break up a large operation like this?
If I was using java or C, I would perform this task in a background thread.
Is there a way to tell the browser to pause execution of the script so it can let its foreground/UI thread work again?
Something like this?
function bigJob() {
for (i = 0; i < 1000000; i++) {
someWork();
sleep(1000);
}
}