Lists
Infinite scroll
Défilement infini
Demo
Loading demo…
A list that loads more items on its own as you near the bottom, with no pagination. It suits aimless browsing of a feed, at the cost of a page end you never reach.
Story
Did you know
Its inventor, Aza Raskin, created it in 2006 and has said publicly that he regrets it. He estimated it wastes the equivalent of 200,000 human lifetimes of scrolling every day.
Timeline
- 2006Aza Raskin designs infinite scroll.
- 2010sFacebook, Twitter and Pinterest make it their engagement engine.
- 2018Raskin says publicly that he regrets his invention.
- 2020sThe "Load more" button returns on e-commerce sites.
Vocabulary
Names
- FR
- Défilement infini, scroll infini, chargement continu
- EN
- Infinite scroll, endless scrolling, lazy loading list, load more, feed
Common uses
- Social and content feeds
- Image search
- Catalogs meant for browsing
Often paired with
The components it usually sits with, by page type, in reading order.
Social feed
See the mock-upCode
<ul id="feed"></ul>
<p id="sentinel">Loading…</p>
<script>
const feed = document.querySelector('#feed')
const sentinel = document.querySelector('#sentinel')
let cursor = ''
let loading = false
async function loadMore() {
if (loading) return
loading = true
const { items, next } = await fetch(`/api/feed?cursor=${cursor}`).then((r) => r.json())
feed.append(...items.map((item) => Object.assign(document.createElement('li'), { textContent: item.title })))
cursor = next
loading = false
if (!next) {
observer.disconnect()
sentinel.textContent = 'No more items'
}
}
// Start loading 400px before the sentinel shows up
const observer = new IntersectionObserver(([e]) => e.isIntersecting && loadMore(), { rootMargin: '400px' })
observer.observe(sentinel)
</script>Good to know
- A "sentinel" element at the end of the list, watched by
IntersectionObserver. Noscrolllistener.rootMarginstarts loading before the sentinel is on screen. - Paginate with a cursor on the API side, not an offset, or duplicates show up when the feed changes.
- Gotcha: if the sentinel is still visible after a load (tall screen, short page), the observer won't fire again. Call
unobserve()thenobserve()to force a fresh check. - Past a few hundred items, virtualize the list (TanStack Virtual) or add
content-visibility: autoto the items.
Accessibility
Must have
- Provide a "Load more" button, at least as a fallback. It gives keyboard and screen reader users control, and it still works if the observer misses a trigger.
- Append new items after the existing ones in the DOM and leave focus alone: Tab carries on from where it was.
Often forgotten
- The footer becomes unreachable. Put its links somewhere else, or switch to a "Load more" button after a few pages.
- With a "Load more" button, move focus to the first new item once it loads. Otherwise people have to tab through the whole list again.
- Announce the load in an
aria-live="polite"region: "20 more results". Without it, nothing says anything happened.
Nice to have
- The APG Feed pattern:
role="feed",<article>items witharia-posinsetandaria-setsize(-1 if the total is unknown), andaria-busy="true"while loading. - Update the URL (
?page=3) withhistory.replaceStateso people find their place again after a reload or going back.