Kelly Mears

Lazy Loading

Deferring the fetch of a resource until it is needed, or until the browser is idle.

Web Platform2 min read215 words15 out · 19 in
also calledDeferred loading

Lazy loading defers fetching a resource — a script, an image, a component, a font — until something establishes that it is needed. It is the most reliable way to reduce what a page costs on first load, because the cheapest byte is the one never requested.

Common forms include images and iframes deferred until near the viewport (now a native HTML attribute), components loaded on interaction or on visibility, and route code fetched when a route is entered. On the server side the equivalent is deferring a slow data fetch behind a streaming boundary so the shell renders immediately.

Two hazards recur. Deferral changes timing, and timing is observable. A script that only loads after a genuine user gesture will not load in an automated test that dispatches a synthetic event at an element rather than at the document — a real class of test that passes locally and fails in headless. Deferral can be undone by accident, since a single eager import elsewhere in the graph can pull the deferred module back into the initial chunk. See Module Graph.

Lazy loading interacts with perceived performance rather than just measured performance: something loading late is only an improvement if the page is usable meanwhile, which is what skeleton states and streaming boundaries provide.

See also13

Critical Rendering Path

The sequence of steps between receiving HTML and painting pixels, and everything that blocks it.

Web Platform18 connections

Code Splitting

Dividing an application bundle so a page downloads only the code it needs.

Web Platform17 connections

Core Web Vitals

Google's small set of user-centered performance metrics: loading, interactivity, and visual stability.

Web Platform28 connections

Islands Architecture

Rendering a page as static HTML with small independently interactive regions.

Web Platform18 connections

React Server Components

Components that execute only on the server and never ship their code to the browser.

Web Platform21 connections

Streaming Response

Delivering a response incrementally as it is produced rather than all at once when complete.

Networks & Distribution20 connections

Server-Side Rendering

Producing a page's HTML on the server so the first response is already content.

Web Platform23 connections

Performance Budget

A committed numeric ceiling on a page's cost, enforced automatically.

Web Platform26 connections

Data URI

A URL that carries its content inside the address itself, used to embed small images in pages and stylesheets without a separate request, and abused for phishing until browsers restricted it.

Web Platform13 connections

Hotlinking

Displaying an image or file on your page straight from someone else's server, so they pay for the traffic, which sites block by checking where requests come from and which courts have treated differently from copying.

Web Platform13 connections

Responsive Images

Offering the browser several versions of an image so it can download the smallest one that still looks sharp on this screen at this layout size.

Web Platform17 connections

Pagination

Splitting a large result set into pages, where the choice between offsets and cursors decides whether deep pages stay fast and whether items get skipped or repeated.

Data & Content6 connections

Above the Fold

The part of a page visible without scrolling, a newspaper idea carried onto the web, where it still matters for first impressions and loading but no longer means people won't scroll.

Design & Interface10 connections

Linked from19