Premium
setTimeout vs requestAnimationFrame for UI updates
A browser UI needs smooth visual updates while the user drags and scrolls. Would you schedule that work with setTimeout or requestAnimationFrame?
- Use setTimeout
- Use requestAnimationFrame
What you’ll build / What this tests
This premium javascript tradeoff battle focuses on setTimeout vs requestAnimationFrame for UI updates. Commit to a direction, justify it with the prompt constraints, and explain when the alternative wins.
Learning goals
- Is the work tied to the next browser paint?
- Is the requirement about elapsed time or visual frames?
- How much does visual smoothness matter?
- What does the scheduling choice communicate?
Key decisions to discuss
- Pick a direction for this exact prompt, not the universal winner.
- State the trade-off that matters most for this scenario.
- Name when another option becomes the better answer.
- Keep the explanation grounded in concrete constraints.
Evaluation rubric
- Strong answers tie the recommendation to the prompt.
- Good tradeoff reasoning explains downsides, not just upsides.
- The answer should show when the recommendation stops being right.
- Follow-up pressure should not break the argument.
Constraints / Requirements
- Which direction would you defend for this prompt, and how would you explain when the other option is…
- Fits best when the work is about time-based delay or scheduling, not paint-synchronized visual updates.
- Fits best when the work updates what the user will see on the next painted frame.
Options on the table
Use setTimeout: Fits best when the work is about time-based delay or scheduling, not paint-synchronized visual…
Use requestAnimationFrame: Fits best when the work updates what the user will see on the next…Common pitfalls
- Arguing from preference instead of prompt constraints.
- Pretending one option is always the winner.
- Ignoring the main downside of the chosen direction.
- Failing to explain when the alternative becomes stronger.
Related questions
Upgrade to FrontendAtlas Premium to access this tradeoff battle. Already upgraded? Sign in to continue.