3 ms·
Eh, you can always do `scrollTo(0, 0)` if you just want the scroll-to-top functionality at the expense of everything else.
by lhorie 6y ago
Eh, you can always do `scrollTo(0, 0)` if you just want the scroll-to-top functionality at the expense of everything else.
- jamescostian 6y agoBut if you want a good user experience, you should really use `scrollTo({ top: 0, left: 0, behavior: 'smooth' })` Smooth scrolling in 42B (minified, not gzipped) rather than 7KB, and supported by 85% of users' browsers (source for that number: https://caniuse.com/mdn-api_scrolltooptions https://caniuse.com/mdn-api_scrolltooptions)
- lhorie 6y agoYeah, that's a good option if you're ok with not-100% browser compatibility.