+ 9

JavaScript stack overflow solution

I want to write something like this: function f(){ //something setTimeout(f,x); } I'm using setTimeout becouse I want to repeat the function again and again, so I'm afraid of stack overflow. But, what value I ought to write instand of x, if I want to be sure that the code will run at old computers, too, but I want the smallest interval of repeating?

7th Nov 2019, 3:39 PM
Dominik Vladař
Dominik Vladař - avatar
1 Answer
+ 3
You might want something like: window.requestAnimationFrame(f); This is especially used in animations, where easier to load animations will be loaded faster while intensive animations load slower.
7th Nov 2019, 3:43 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar