Riff / Built on the open web / Media

Lazy loading

Fetches list thumbnails only as they scroll into view.

The Listen page: the library, nine albums as drawn record covers
Each cover in the grid is a lazy-loaded image; those below the fold wait for a scroll.

How Riff uses it

Every thumbnail in a list is marked loading="lazy": the art on each track row, each item in Up next, and each record cover in the library grid. The cover of the current track is not lazy.

Why

A post or library can have dozens of covers, and the browser should not fetch them all before the listener scrolls.

Without it

A browser without the attribute loads the images eagerly.

Where

Links open the source at the commit this page was published from.

Reference: Lazy loading on MDN.