/    Sign up×
Community /Pin to ProfileBookmark

Prevent browser stall warning

I have a computational application in JavaScript that has 0.01% chance of causing the browser to give user a script stalling warning.

Assume the script continues without the warning, it would finish in under 5 seconds. I was wondering if anyone know how to prevent that warning from ever popping up.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyNov 28.2008 — You can prevent it by scheduling your computations in sections. The first section starts the next section as a separate function on a timer:
[CODE]function firstPart()
{
...etc...
window.setTimeout("secondPart()", 100);
}[/CODE]

Then, that second function can start the next section as a separate function on a timer:
[CODE]function secondPart()
{
...etc...
window.setTimeout("thirdPart()", 100);
}[/CODE]

The last function, in the series, outputs the results of the computations and then just ends:
[CODE]function thirdPart()
{
...etc...
return;
}[/CODE]

The little releases between functions helps the browser to have a chance to breath.
Copy linkTweet thisAlerts:
@scragarNov 28.2008 — The warning is there to stop excessive ram or CPU usage, if you can break that usage up it can prevent the warning, either rewrite your code to reduce load, or add break points in the code where you can do something like:
function intensiveBit1(){
// some stuff here
setTimeout(intensiveBit2, 500);// wait half a sec
}
function intensiveBit2(){
// then some more stuff
setTimeout(intensiveBit3, 500);// wait half a sec
}
function intensiveBit3(){
// last bits of your function or whatever
}
×

Success!

Help @voidvector spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...