Dries Buytaert

Simple JavaScript search

When I have a little bit of time, I enjoy working on my website. I sand it down, polish it, or smoothen a rough edge.

Just this week I added a search feature to my blog posts page.

I often have to find links to old blog posts. To do so, I navigate to https://dri.es/blog, which provides a long list of every blog post I've ever written. From there, I type ⌘-F to use my browser's built-in search.

I like that my blog posts page is one long list that is easy to search. What I don't like is that when there is more than one match, iterating through the results causes the search experience to jump around.

The new search feature smoothens that rough edge. Instead of jumping around, it filters the list. It creates a nice overview. Try it out, and you'll see that it makes a big difference.

Amazing what 30 lines of vanilla JavaScript code can do!

— Dries Buytaert

39 sec read time