Explaining requestAnimationFrame in 256 characters or fewer
source link: https://dev.to/ben/explaining-requestanimationframe-in-256-characters-or-fewer-29n6
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
This is a submission for DEV Challenge v24.03.20, One Byte Explainer: Browser API or Feature.
(I'm a challenge judge so this is participation-only 😋)
Explainer
requestAnimationFrame
is a method which instructs the browser to sync animations with the browser's repaint times.
It prevents glitches in animation-heavy scenarios, but adds complexity and extra overhead, so it should only be used when necessary.
Additional Context
If you're experiencing browser jank, this sometimes works like magic, and I'm surprised it isn't more well-known or widely used.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK