$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #190

Which fix removes the bug?

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