Agent Wranglers

WEB-40Recommended

Hint only what speeds up the first paint

Preload only what the first paint needs, prefetch likely next pages, and preconnect only to other origins you are certain to use.

How to do it

Preload the LCP image only if the browser can't find it early in the HTML. Use one preload per screen size (media), so each device downloads one image. Don't preload fonts unless you have measured that it doesn't delay first paint. Preconnect only to other origins needed during load. Keep hints few. Add each one only after measuring it, and remove hints that don't help. Measure each hint as Measure speed in visitors' browsers says.

Examples

HTML example

<!-- only when the hero is not in the HTML (for example a CSS background) -->
<link rel="preload" as="image" href="/assets/hero-768-f0c7bcf5bb.avif" media="(max-width: 600px)">
<link rel="preload" as="image" href="/hero-1536.avif" media="(min-width: 601px)">
<link rel="preconnect" href="https://cdn.example.com" crossorigin>

How to check

Compare first paint and LCP with and without each hint in a browser. Every hint left has a before and after measurement behind it.

Measured

On a reference site, two font preloads delayed first paint by 80 ms in Chrome at a 100 ms round trip. Lighthouse's simulation reported the opposite. Removing the hero preload and fetchpriority left Lighthouse LCP unchanged at 2.1 s, because the image was early in the HTML.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/performance/preload-prefetch-preconnect">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.