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

  • SEARCH
  • Home
  • 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 8042795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:42:20+00:00 2026-06-05T04:42:20+00:00

http://jsfiddle.net/Codemonkey/ye5qv/2/ I am experimenting with writing large workloads to recur using setInterval so that

  • 0

http://jsfiddle.net/Codemonkey/ye5qv/2/

I am experimenting with writing large workloads to recur using setInterval so that the browser can catch it’s breath between each iteration of work. In my example above I’m giving the browser 100ms of rest between each interval of fibonacci calculations, but the browser is still frozen from the moment fib() is called to the moment the callback is called. Note: In my example, the fibo function isn’t called before one second after the document load so you can clearly see it freeze for a few seconds

Exactly why isn’t this method working, and how can I make it work? Alternatively, which other method could achieve the same goal result? To reiterate, the goal of using setInterval to split up the work is that the browser should never freeze or studder during the process.

I’m using chrome and I’m mainly concerned with the V8 engine, but an x-browser compatible solution is a bonus

  • 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-06-05T04:42:23+00:00Added an answer on June 5, 2026 at 4:42 am

    The problem is that your code never reaches the point where it calls setTimeout to give control back to the browser.

    Change this:

    for(var i = start; i < i+workload; i++)
    

    to:

    for(var i = start; i < start+workload; i++)
    

    As workload is a positive number, i < i + workload will never be false, so you have an infinite loop.


    You don’t have to wait for 100 ms when giving control back to the browser, just calling setTimout is enough to make the browser handle events, so you can use the time 0:

    setTimeout(function() {
      processor(start + workload);
    }, 0);
    

    Demo: http://jsfiddle.net/Guffa/ye5qv/3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/motocomdigital/uTV5k/18/ I've updated using toggle instead on click - though still can't get smooth
http://jsfiddle.net/RedKnight91/Z6Ueu/4/ Hi! Look at that last menu (on the bottom). When you hover on
http://jsfiddle.net/studioband/pG87G/6/ This link is apart of a website that I am designing. I have
http://jsfiddle.net/BXNE9/1/ I want to open div through anchor point using related link. when I
http://jsfiddle.net/3V6MM/ Please tell me how can I write common style for class=property-title to display
http://jsfiddle.net/9BCrs/5/ I have this set up to load a file into a DIV using
http://jsfiddle.net/fJkBU/1/ That's my code. Basically, I have an iFrame whose source may change. I
http://jsfiddle.net/cwUcM/ I've gone through all of the other threads that seems to have a
http://jsfiddle.net/ujTDf/1/ link text Can anybody help please. The div/form doesn't switsch automaticly in other
http://jsfiddle.net/AndyMP/nUhhf/1/ This is a simplified situation where I have a DIV that animates downwards

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.