Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6099447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:16:28+00:00 2026-05-23T13:16:28+00:00

UPDATE (5 July 2013): I’ve learned much since I originally asked this question. In

  • 0

UPDATE (5 July 2013):

I’ve learned much since I originally asked this question. In one of the comments below it was suggested that I re-approach the task and find a way to solve it without risk of blocking the UI. I said it was impossible, the function must run as is. I don’t actually remember what I was trying to accomplish with the function, but I’m certain that the commenter was right, and I was wrong. If you stumble upon this question and are in a similar situation as I was, then consider very seriously the possibility that your approach is flawed.

You might also want to look into web workers.

Here is where you can expect them to work.


Original Question:

Rather than get overly specific to my problem, I’ll keep this generic so other people who stumble upon this can find it useful.

I have a function that accepts one parameter, a string. If the string is short the function runs fine and completes in a timely fashion. If, however, the string that’s passed in is too long the script runs for a bit, then eventually times out and returns the browser’s slow script dialog that allows the user to kill the script.

I would like to prevent that from happening so the script can continue to its terminus.

How can this be done?

A side note: If I can get this working, I would also like to make a status bar, similar to the one you see when loading gmail, appear so the user knows things are happening.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:16:29+00:00Added an answer on May 23, 2026 at 1:16 pm

    No way you can disable that behavior in any browser by script. Imagine the impact, disable that feature and call a while(1). Pretty bad.

    It’s on you to create code which does not block the browser for “too long”. There are a ton if best-practice patterns. I always recommend to try to break down your algorythm into smaller chunks. Combine that with a runaway-timer and a loop which makes sure that any operation does not run for longer than 100ms (for instance).

    var sequence = ['foo', 'bar', 'baz', 'base', 'ball', 'hello', 'world', '100k more'],
        start = Date.now();
    
    setTimeout(function _worker() {
        do {
           var element = sequence.shift();
           // do something with element
        } while( sequence.length && (Date.now() - start < 100) );
    
        if( sequence.length )
            setTimeout(_worker, 25);
    }, 25);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: Check out this follow-up question: Gem Update on Windows - is it broken?
Update: Please read this question in the context of design principles, elegance, expression of
UPDATE - No need to answer this now, I have solved below. Hi, I'm
Update : Clarified and expanded, since the original question was simplified too far I
Update: Solved, with code I got it working, see my answer below for the
Update: giving a much more thorough example. The first two solutions offered were right
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here:
Update : this is more-or-less a dupe , and it turns out to be
Update: the much better answer has little to do with refactoring, but has to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.