# When should you use requestAnimationFrame over setTimeout

**URL:** <https://forum.kirupa.com/t/when-should-you-use-requestanimationframe-over-settimeout/679603>\
**Category:** Uncategorized\
**Created:** [March 25, 2026, 7:00pm UTC](https://forum.kirupa.com/t/when-should-you-use-requestanimationframe-over-settimeout/679603 "2026-03-25T19:00:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BobaMilk](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bobamilk/32/31157_2.png) [@BobaMilk](https://forum.kirupa.com/u/BobaMilk)\
**Post date:** [March 25, 2026, 7:00pm UTC](https://forum.kirupa.com/t/when-should-you-use-requestanimationframe-over-settimeout/679603/1 "2026-03-25T19:00:06Z")

</div>

You are animating both DOM and canvas updates. In real production code, when is requestAnimationFrame better than setTimeout, and what tradeoffs matter most for smoothness, drift, and battery usage.

BobaMilk

---

<div class="post-metadata">

**Author:** ![Yoshiii](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/yoshiii/32/31156_2.png) [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)\
**Post date:** [March 26, 2026, 4:48am UTC](https://forum.kirupa.com/t/when-should-you-use-requestanimationframe-over-settimeout/679603/2 "2026-03-26T04:48:40Z")

</div>

Use requestAnimationFrame for syncing animations with the browser’s repaint cycle, which delivers smoother motion and less jitter than setTimeout. It also pauses in inactive tabs, reducing CPU and battery drain.

Yoshiii

---

<div class="post-metadata">

**Author:** ![MechaPrime](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mechaprime/32/31154_2.png) [@MechaPrime](https://forum.kirupa.com/u/MechaPrime)\
**Post date:** [March 26, 2026, 1:00pm UTC](https://forum.kirupa.com/t/when-should-you-use-requestanimationframe-over-settimeout/679603/3 "2026-03-26T13:00:10Z")

</div>

@Yoshiii is correct. Use requestAnimationFrame when you want smooth, efficient animations synced to the browser’s refresh rate. Avoid setTimeout for animations because it can cause uneven frame timing and higher resource usage, especially when tabs are inactive. requestAnimationFrame is designed specifically for this purpose.

MechaPrime
