I am making a website which has a lot of JavaScript. Will use of setInterval() hurt the performance of my website?
Asked
Active
Viewed 1,016 times
5
-
What kind of performance are you interested in? – Jeff Dec 09 '12 at 22:27
-
setInterval(function(){ // some script here }, 1) – Idrizi.A Dec 09 '12 at 22:27
-
You might be interested in [this post](http://stackoverflow.com/questions/7648557/javascript-setinterval-behaviour-with-0-milliseconds). The browser sets a minimum that setInterval can run at (apparently around 10ms.) – theabraham Dec 09 '12 at 22:28
-
It depends on the context...and that makes your question in its current state hard to answer... – rene Dec 09 '12 at 22:28
-
2Running something once a millisecond is probably going to hurt performance, and you aren't guaranteed to actually have it run every millisecond anyway. Best to describe why you want to use `setInterval`. – nneonneo Dec 09 '12 at 22:28
-
If it is not good to set 1 millisecond, whats the solution? – Idrizi.A Dec 09 '12 at 22:30
-
4@Enve — The depends on what the *problem* is. "I want to do *something* every millisecond" is too vague. – Quentin Dec 09 '12 at 22:31
1 Answers
3
Depends what for you're using it and how. It can be really helpful if you want to do things asynchronously.
(would be really nice to see some code - then I would be able to say something more)

lupatus
- 4,208
- 17
- 19