Skip to content

Instantly share code, notes, and snippets.

View winng51's full-sized avatar

winng winng51

View GitHub Profile
@eyecatchup
eyecatchup / smooth-scrolling-polyfill.md
Last active September 8, 2023 06:32
Smooth Scroll behavior polyfill

The Scroll Behavior specification has been introduced as an extension of the Window interface to allow for the developer to opt in to native smooth scrolling. To date this has only been implemented in Chrome, Firefox and Opera.

There's a complete polyfill here (3.3KB minified). But most of the times, the following is enough for me (641 bytes minified):

smooth-scrolling-poyfill.js

Use as: scrollToElem('#elem-selector');