Which fix removes the bug?
window.addEventListener('scroll', () => recalcLayout());
// recalcLayout reads offsetHeight
- Throttle the handler
- Use the capture phase
- Bind it to document
- Cache the element
Scroll fires per frame or faster, and each forced layout read stalls rendering.
Play Problem Solving ▸