Mid-level Track Roadmap

Infinite scroll

This course builds infinite scroll in a Rails app with tools the app already has. It starts by comparing offset pagination with Pagy against infinite scroll and explains when each one fits. It then covers IntersectionObserver and the sentinel pattern, Turbo Frames for scoped and lazy loading, and the Turbo Streams load-more pattern from the comment thread. A reusable Stimulus controller combines these pieces. The last lessons handle loading states, errors, scroll restoration, SEO and accessibility, then trace the full flow from query to rendered content.

What you'll learn

  • ✓When to use pagination, a load-more button or infinite scroll
  • ✓Detecting the end of a list with IntersectionObserver and a sentinel element
  • ✓Appending records with Turbo Streams and the fetch N+1, use N pattern
  • ✓Building a reusable infinite-scroll Stimulus controller
  • ✓Handling loading states, errors, scroll restoration, SEO and accessibility
  • ✓Testing the complete flow with system tests
Free preview · Lesson 1 4 min read

Pagination vs infinite scroll

A web page with 500 records can't render them all at once. There are two solutions: pagination, which splits records into separate pages the user moves between, and infinite scroll, which loads more records as the user scrolls toward the bottom. Each pattern has trade-offs, and a well-built Rails…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...