A teammate scrolled the product list on their phone and said it felt "sticky" — not broken, just a little behind, like the page was thinking about it before it moved. On a laptop trackpad it was perfectly smooth. Same code, same list, same 12-line scroll handler that did almost nothing: check scrollY , toggle a "back to top" button.
Twelve lines. Nothing in it that should cost more than a millisecond. And yet, on a phone, every scroll felt like it had a half-beat of drag.
The fix that didn't fix it
The obvious read is "the handler is too slow," so that's where the first hour went:
list . addEventListener ( " scroll " , () => { backToTop . hidden = list . scrollTop < 400 ; });
Enter fullscreen mode
Exit fullscreen mode
Wait — not even scroll . The actual listener was on touchmove , added so the button could react mid-gesture instead of waiting for the scroll to settle:
list . addEventListener ( " touchmove " , () => { backToTop . hidden = list .…