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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:06:48+00:00 2026-06-13T18:06:48+00:00

I’m working on a website mainly for mobile and tablet. I just want to

  • 0

I’m working on a website mainly for mobile and tablet.
I just want to ask is there any drawback on using a bit too much Interval?
As for now i’m using 1 interval with 5000ms to get and check current time and 1 interval with 100ms to check if the device’s width change (for responsive purpose)

I’ve heard my senior said that we should try to use those interval as less as possible, it may cause some hole and lag and such. Is it true?

  • 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-13T18:06:51+00:00Added an answer on June 13, 2026 at 6:06 pm

    Update:
    Check this page, and all linked articles of interest: Web Workers, Asynchronous events and Timeout in particular


    The main disadvantage when using intervals is down to the fact that all current JS implementations that I know of are single threaded. So if you set an interval to call a function every 100ms, and another every 500ms, the intervals won’t be executed simultaneously. If you rely heavily on the first interval having returned in the code you execute with the second interval, you’re going to run into trouble sooner or later.

    Another thing you might notice is that the intervals are not very accurate. 100ms should be seen as ~100ms, and make no mistake the difference between the set interval and the actual interval can be quite big (an interval of 100ms can turn out to be as much as 150ms easily).

    Bottom line, your chief is right, avoid as much as possible. However, sometimes there is no alternative but to use intervals. In which case, List all intervals, find the smallest common denominator and set one big interval that uses a closure to call the various functions when “their time has come”

    var allIntervals = (function()
    {
        var interval100MS = function(){};
        var interval200MS = function(){};//etc...
        var timesCalled = 0;
        var timer = setInterval(function()
        {
           if (++timesCalled%2)
           {
               return interval100MS();
           }
           interval100MS();
           return interval200MS();
        },100);
        return timer;//<-- expose so you can clear the interval, of course
    }());
    

    You can expand this to return an object that allows you to set extra intervals, change the main interval time, unset certain intervals etc…

    Edit
    I overlooked the fact that you’re using an interval. That’s just not necessary: window.onresize or window.addEventListener('resize',handlerFunction,false); will do just that. Behind the scenes, JS has an event cycle/loop that takes care of things much more efficiently than any kind of self-made code.
    It’s often said that the best developers are, in essence, lazy people: They’ll go through a lot of trouble, just to be sure that what they need hasn’t been done before. If they find out about something that does what they need, they’ll use that, rather than writing the same thing themselves.

    Anyway, I’ve added a link on the very top of my answer, and I’m going to add it here a second time. Check it out, especially the references to web workers, which might prove useful if you’re checking the time (not sure how/why/what you’re doing there).

    • 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
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into

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.