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 8023145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:29:06+00:00 2026-06-04T22:29:06+00:00

I’ve run into a strange issue in Firefox 12. setTimeout() doesn’t seem to always

  • 0

I’ve run into a strange issue in Firefox 12. setTimeout() doesn’t seem to always wait the appropriate length. Or perhaps it’s the date’s milliseconds that don’t jive?

Check out this fiddle. Essentially, a setTimeout of 100ms seems to run anywhere between 80ms and 110ms. More I can understand, based on John Resig’s explanation of timers. But less?

You may have to refresh it once or twice to see the issue, as it sometimes works correctly on the first run. It seems to work spifftacular in IE and Chrome.

Here’s the code I’m using in my fiddle:

var txt = '',
    TIMEOUT_LENGTH = 100,
    _now;

now = Date.now || function() { return new Date().getTime() };

function log(time) {
    c = time < 100? 'class="error"' : '';
    $('#log').append('<p '+c+'>waited ' + time + '</p>');
}

function defer() {
    var d = $.Deferred(),
        start = now();
    setTimeout(function() {
        d.resolve(now() - start);
    }, TIMEOUT_LENGTH);
    return d.promise();
}

for (var i = 0; i < 20; i++) {
    defer().then(log);
}

Here’s a sample of the quirky output:

enter image description here

Here’s my browser info:

enter image description here

And thanks so much for reading my question! I hope someone can shed some light into this.

MORE INFO

I worked around the problem by using setInterval() and checking each increment to see if the required time has passed. See this fiddle.

However, I’m still very interested to hear if anyone can shed some light into the source of the issue

  • 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-04T22:29:08+00:00Added an answer on June 4, 2026 at 10:29 pm

    Yes. setTimeout‘s accuracy is based off many factors, and isn’t guaranteed to always execute at the exact time you specify.

    I cannot say this with any authority, but I’ll hazard a guess that Firefox, in an attempt to seem faster, will speed up the JS engine temporarily to get everything in motion (which is interesting, because in my experience, timer-based functions actually run slower at first initially in my version of firefox).

    Neither setTimeout nor setInterval promise that they will execute at the exact right time, as the link you posted stated. However, with setInterval, you get the benefit of the timer loop doing what it can to “correct itself” by catching up if it lags too far behind, so for whatever you’re trying to do, it may be more appropriate.

    Anyway, here’s my results on my Macbook 10.6.8:

    Firefox 5.0.1:

    waited 92
    waited 92
    waited 93
    waited 93
    waited 93
    waited 93
    waited 93
    waited 94
    waited 93
    waited 93
    waited 93
    waited 93
    waited 94
    waited 94
    waited 94
    waited 94
    waited 94
    waited 95
    waited 96
    waited 96
    

    Safari 5.1.5:

    waited 100
    waited 104
    waited 104
    waited 103
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    

    Chrome 19.0.1084.52:

    waited 101
    waited 103
    waited 103
    waited 104
    waited 104
    waited 103
    waited 103
    waited 103
    waited 103
    waited 103
    waited 103
    waited 103
    waited 103
    waited 103
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    waited 104
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I would like to run a str_replace or preg_replace which looks for certain words
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.