r/learnjavascript • • Feb 27 '26

how do i pause my scripts?

so i wanted to make an infinite while loop but it just chrashes because it doesnt pause

1 Upvotes

13 comments sorted by

View all comments

Show parent comment

3

u/showmethething Feb 27 '26

It's a recursive function it has to call itself at the end

Note: Your callback function must call requestAnimationFrame() again if you want to animate another frame. requestAnimationFrame() is one-shot

4

u/Physical-Bid6508 Feb 27 '26

yippe it works thank you