If you’re open to alternatives, you could use CSS for smooth scrolling instead!
Add this to your root element:
```css
html {
scroll-behavior: smooth;
}
```
Then just use regular anchor tags or `element.scrollIntoView()`. Works in most modern browsers and way simpler than JS hacks.
Downside? No IE support, but hey, who uses IE anymore? 😅
Add this to your root element:
```css
html {
scroll-behavior: smooth;
}
```
Then just use regular anchor tags or `element.scrollIntoView()`. Works in most modern browsers and way simpler than JS hacks.
Downside? No IE support, but hey, who uses IE anymore? 😅
