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.
Want super smooth, fast infinite scrolling in Inertia? In this snippet, we'll seed our database with a bunch of data and start building the solution, refactoring along the way until we perfect it.