Scrapeless Wiki

What Is Infinite Scroll? – Definition and How It Works

Informational P2 what is infinite scroll

Learn how infinite scroll loads content on demand, which mechanism triggers it, and why the underlying request is the better collection target.

Infinite scroll loads more content as a visitor approaches the end of a list, instead of presenting numbered pages. There is still pagination underneath; only the control has changed.

1. How It Works

  1. The page renders an initial batch.
  2. A sentinel element sits below the list, and an observer watches for it entering the viewport.
  3. When it does, the page requests the next batch.
  4. The response is appended and the sentinel moves down.

Modern implementations use an intersection observer rather than scroll event handlers, which is why the loading feels smooth and why nothing happens if content never enters the viewport.

2. The Request Underneath Is Ordinary Pagination

The background call almost always looks like a conventional paginated API request:

GET /api/products?cursor=eyJpZCI6NDE5Mn0&limit=24

That is the collection target. Driving the interface β€” scrolling, waiting, scrolling again β€” reproduces something that can be requested directly in one call per batch.

3. Why the Endpoint Is Better

Approach Cost per batch Stability
Scroll the page in a browser A browser session, several seconds per batch Depends on layout and timing
Call the endpoint One HTTP request Depends on a data contract

Layouts change far more often than data contracts, and a browser costs orders of magnitude more per batch. Opening the network panel to find the request is the highest-value step available.

4. When You Must Scroll

If no reachable endpoint exists, the browser loop needs a correct termination condition:

  1. Record the current item count.
  2. Scroll to the bottom.
  3. Wait for the count to increase, with a timeout.
  4. If it did not increase, stop.
  5. Cap total iterations regardless.

Waiting a fixed interval and scrolling a fixed number of times is the fragile version β€” it either stops early or wastes time.

5. Common Pitfalls

  • Lazy-loaded media only loads when in view, so images may be absent from items scrolled past quickly.
  • Virtualised lists remove off-screen items from the DOM, so the full set never exists at once β€” the endpoint is the only complete source.
  • Depth limits stop loading after a threshold, and narrowing the query is the answer.
  • Duplicate items appear when the underlying order is unstable between requests.

Virtualisation is the one that surprises people: scrolling to the end and reading the DOM returns only the last visible window.

6. Detecting Which You Have

Scroll a long way, then count the items present in the DOM. If the count stops growing while the scrollbar keeps moving, the list is virtualised.

That single check decides whether scrolling can ever produce a complete collection.

7. Accessibility and Design Notes

Infinite scroll makes footers hard to reach, breaks bookmarking of a position, and complicates keyboard navigation. Many implementations therefore add a "load more" button or retain conventional pagination alongside β€” which, conveniently, is also easier to collect from.

8. Summary

Infinite scroll requests further batches when a sentinel enters the viewport, and the request it makes is ordinary cursor or offset pagination.

Call that endpoint directly wherever possible. If you must scroll, terminate on the item count ceasing to grow, cap the loop, and check for virtualisation β€” because a virtualised list never holds the whole set in the DOM at all.