1

I need to display a notice every hour, or at certain hourly intervals. I was wondering what the effect on performance is of having such a large time out time?

setTimeout(function(){ ... } ,60*60*1000)

The timer doesn't have to be perfect and can be a couple of milliseconds out.

Jan Swart
  • 6,761
  • 10
  • 36
  • 45

2 Answers2

1

the answer is no... you don't have performace problems... but i think you needs to use SetInterval instead SetTimeout to repeat the call every x time

lem2802
  • 1,152
  • 7
  • 18
1

setTimeOut() (or setInterval() for that matter) itself is not expensive (performance-wise) at all: after all, it's just a check to see if the determined time has passed.

The "time" you determine doesn't change the performance at all. A setTimeOut(function() {;}, 100); is as expensive as setTimeOut(function() {;}, 1000);.

What might slow down your site/app is the code that has to run when the timeout triggers.

Jordumus
  • 2,763
  • 2
  • 21
  • 38