From Janky to Buttery Smooth Scrolling

Written by Selvin Ortiz on April 10, 2024

If there’s one thing I’ve learned from end­less hours of scrolling — cod­ing, read­ing docs, or just bing­ing YouTube — it’s the val­ue of smooth scrolling.

It’s a game-changer.

Today, I’m div­ing deep into how you can achieve that but­tery smooth scroll on Mac and Win­dows. And if you run a web­site or blog, stick around. I’ve got some tips to make your site a pleas­ant place to scroll through.

What Exact­ly is Smooth Scrolling? #

Ever notice how some scrolling feels like glid­ing on ice while oth­ers more like hop­ping on rocks? That’s the dif­fer­ence smooth scrolling makes. It trans­forms your scrolling expe­ri­ence from frus­trat­ing to flu­id. Just pic­ture a side-by-side com­par­i­son: on one side, you’ve got that janky, stut­ter­ing scroll. On the oth­er, smooth as silk. That’s what we’re aim­ing for.

Smooth Scrolling with Log­itech Options+ #

For those rock­ing a Log­itech mouse or touch­pad, you’re halfway there. Logitech’s Logi Options+ soft­ware is your tick­et to smooth scrolling bliss. It’s pret­ty straightforward:

Just like that, you’re set.

Why Smooth­Scroll is My Go-To #

Now, let me intro­duce you to the MVP: SmoothScroll.

Here is why I love SmoothScroll:

Just remem­ber, if you’ve got Logi Options+ rolling, turn off its smooth scrolling. They tend to clash.

Smooth Scrolling for Your Web­site #

Here’s the cher­ry on top.

Mak­ing sure your web­site or blog offers smooth scrolling can seri­ous­ly upgrade your visitor’s experience.

Here’s how:

Before you go too far down the rab­bit hole of JavaScript-based smooth scrolling, know that there is a native CSS fea­ture for this: scroll-behavior.

html {
  scroll-behavior: smooth;
}

And before you reach for a library like jQuery to help, there is also a native JavaScript ver­sion of smooth scrolling, like this:

// Scroll to specific values
// scrollTo is the same
window.scroll({
  top: 2500, 
  left: 0, 
  behavior: 'smooth'
});

// Scroll certain amounts from current position 
window.scrollBy({ 
  top: 100, // could be negative value
  left: 0, 
  behavior: 'smooth' 
});

// Scroll to a certain element
document.querySelector('.hello').scrollIntoView({ 
  behavior: 'smooth' 
});

Cred­its: Christ Coy­er | CSS Tricks

P.S. If you pre­fer videos, make sure to check out My YouTube Channel

Who wrote this article?

Selvin Ortizđź‘‹

I'm a software engineer and content creator.
I help brands develop software and content strategies đźš€

On this blog, I write about software development, emerging technology, technical leadership, and content creation âś¨

Here are a few more articles you might enjoy

And a few videos from my YouTube channel

Join my Newsletter

Get the latest updates on my work, articles, and other interesting news about generative AI delivered right to your inbox twice a month. No spam, guaranteed đź™Ś