www.webdeveloper.com
Results 1 to 3 of 3

Thread: Prevent browser stall warning

  1. #1
    Join Date
    Oct 2008
    Posts
    349

    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.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,666
    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);
    }
    Then, that second function can start the next section as a separate function on a timer:
    Code:
    function secondPart()
    {
        ...etc...
        window.setTimeout("thirdPart()", 100);
    }
    The last function, in the series, outputs the results of the computations and then just ends:
    Code:
    function thirdPart()
    {
        ...etc...
        return;
    }
    The little releases between functions helps the browser to have a chance to breath.

  3. #3
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    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:
    Code:
    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
    }
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles