JavaScript · Senior · Question 57 of 75
When is requestIdleCallback appropriate?
- ✓Correct answer: For low-priority work (analytics batching, prefetching) that can wait until the browser is idle
- 2For animations that must run every frame
- 3For handling user clicks
Explanation
The callback gets a deadline (timeRemaining()); do small chunks and reschedule. Pass timeout to guarantee it runs eventually on busy pages.