Here's how to implement a simple, clean pattern for infinite scrolling content in Vue. We'll refactor to make it more reusable, too.
Infinite scrolling in Livewire can be simple to implement, but things slow down as more data rolls in. In this short course, we’ll look at a technique to load batches of records upfront, then fetch and render each batch only when its needed. The result? No drop in performance, regardless of how many records a user scrolls through.
Adding infinite scroll to Livewire can be tricky. Let’s implement a really easy (but slow) solution, and then look at a better way to continuously load more records as we scroll the page. We’ll also include a really easy way to implement the Intersection Observer API with an Alpine plugin, and add some enhancements to create a nice, smooth scrolling experience.