Page Speed Optimization

Match responsive image preloads to the rendered image

A practical workflow for diagnosing mismatched responsive image preloads.

A browser window connects through a single teal path to one of three differently sized image cards.

Preload a responsive image only when you can make the early request match the image the page will actually display. Compare the selected URLs at each layout, fix the selection rules first, and remove the hint if it adds traffic without moving useful work earlier.

Define the request you are trying to improve

A page can contain a perfectly valid preload and still download an unnecessary image. The hint might name the desktop hero while the rendered image selects a mobile variant. Both files can look correct when opened separately. The problem is the relationship between the early request and the later consumer.

Choose one representative page and identify the image that matters in its first viewport. Record whether that image appears in the initial document, arrives through a script, or comes from a stylesheet. Do not start by adding hints to every image that looks important in the content management system. A preload is a decision about an imminent request, not an editorial importance label.

Write down the intended outcome before editing: the required image should become discoverable earlier, the browser should use that resource, and the change should not create an avoidable competing transfer. Those are separate checks. An earlier request is not enough if it retrieves a file that is never displayed.

If you have not yet established the image's displayed size, format and variants, use the image optimization guide first. This procedure assumes those assets already exist and concentrates on keeping their loading instructions consistent.

Compare the early and final selection rules

For a responsive image, review the candidate list and expected display width together. The preload uses imagesrcset and imagesizes; the image uses srcset and sizes. The web.dev guidance on responsive image preloads explains how these pairs allow early loading to follow the image's selection logic.

Build a small comparison record from the HTML actually delivered to the browser. Check generated output, not only the template in your editor. An optimization plugin, component wrapper or image service may alter a URL or attribute after the template has been processed.

Item Compare before testing Typical question
Candidate URLs Preload list and image list Do both refer to the same generated assets?
Width descriptors Declared width and actual file width Does each label describe its file correctly?
Display width imagesizes, sizes and the layout Do the instructions match the real container?
Media conditions Hint and displayed source Could two competing hints apply together?
Request settings Resource destination and relevant CORS settings Can the later image use the early request?

Do not guess a fixed “mobile image” from the viewport width alone. Device pixel ratio and browser choices also affect selection. Your job is to supply consistent candidates and accurate layout information, then observe the chosen resource. It is not to force every narrow screen to fetch the smallest file.

Start each comparison with a fresh navigation

Open developer tools before loading the page and capture a baseline without the proposed change. Keep the viewport, device scale, browser version and network conditions consistent. Save the request URLs and a short note describing the first visible layout so another person can repeat the comparison.

Use a fresh navigation for each viewport condition. Resizing an already loaded page can leave a previously fetched larger image available. That can be useful for the visitor, but it makes a poor test of which candidate a new visit would initially request. Separate cold-load checks from repeat visits and state which one your result describes.

Filter the Network panel by images, but inspect the full request path when necessary. A URL can redirect or acquire transformation parameters. Compare the actual chosen source with the actual request, rather than comparing two friendly filenames displayed in different tools.

This small console sample reports the source selected for an image you identify. Replace the selector with one that matches your page; it is an inspection aid, not code to ship to visitors.

js
const hero = document.querySelector(".article-hero");
if (hero instanceof HTMLImageElement) {
  console.table({
    selectedURL: hero.currentSrc,
    declaredSizes: hero.sizes,
    displayedWidth: hero.getBoundingClientRect().width,
    deviceScale: window.devicePixelRatio
  });
}

Record the result after the image has been selected. An empty value at an earlier moment does not establish a broken preload. Likewise, this sample does not prove that a network transfer was reused; use it alongside the request record.

Find the cause of an apparent duplicate

When two image requests appear, first ask whether they are actually alternatives for the same visible image. A gallery thumbnail and a hero can legitimately show the same subject in different sizes. Removing one because the filenames resemble each other could break a different component.

If both requests belong to the hero, compare their complete URLs and selection conditions. A fixed preload can choose one file while a responsive image chooses another. Two overlapping media rules can also make an intended either-or choice behave like two independent requests. Keep the repair tied to the mismatch you can demonstrate.

Then inspect format selection. Offering several formats through a picture component does not mean every supported format should be preloaded. A browser may support more than one, while the displayed image needs only one source. Avoid turning fallback choices into simultaneous downloads merely because each hint looks valid in isolation.

Finally, examine request configuration and the initiator. The as value should describe an image, and relevant cross-origin settings must agree with how the image is fetched. Do not add or remove crossorigin indiscriminately: determine the intended mode and whether the image's use requires it. A console warning is a useful lead, but the final judgment should be based on the resource the page consumes.

Keep responsive hints in the document

For viewport-dependent selection, put the responsive preload in the HTML document where its selection context is available. Do not assume that an HTTP Link header or a 103 Early Hints response can make the same responsive choice before the document exists. A copied header example may be appropriate for a fixed resource yet unsuitable for your candidate list.

Keep viewport information early and stable. If a template changes the viewport configuration after a hint has been processed, your supposedly matching instructions may have been evaluated under different conditions. Treat the document head as part of the implementation, not as an unrelated block maintained by another plugin.

A script-inserted hero is a reasonable place to investigate discovery delay. Before introducing a preload, also consider whether the necessary image markup can be present in the initial document. That alternative can reduce the number of independent instructions you must maintain. Choose according to the component's real constraints, rather than declaring either approach universally best.

For art direction, a mobile crop and a desktop crop may represent different compositions rather than different widths of one file. Review the selection branch as well as its size. A successful request for the wrong crop is still the wrong outcome, even if the byte count looks attractive.

Test usefulness as well as correctness

A matching request is necessary, but it does not by itself justify keeping the hint. Compare when the useful image starts loading and when the relevant content appears. If the browser already discovers the image promptly, the additional instruction may add maintenance work without a meaningful benefit.

Look beyond the image's own row. Earlier image loading can compete with other work. Keep the first viewport usable, including its text and essential styling, and inspect the result on more than one representative connection. Do not report a universal speed improvement from a single favorable reload.

Run several comparable checks and retain the raw observations rather than only the best screenshot. Note variation and avoid assigning a precise saving when the evidence is noisy. The PageSpeed Insights reading guide can help separate a lab result from the broader experience reported by real visits.

Also check behavior after the image or layout changes. A content editor might replace the hero, a designer might narrow its container, or a release might change generated file names. Make the preload and rendered image derive from the same underlying image data wherever practical, so an ordinary edit does not silently leave an outdated hint behind.

Leave a repair that another person can verify

Document the page tested, the relevant viewport conditions, the mismatched instructions and the specific correction. Include the selected URL before and after, together with whether an extra transfer disappeared and whether useful loading began earlier. Keep factual observations separate from the explanation you infer from them.

Set a simple acceptance rule for the component: its intended source is selected, no unnecessary alternative is fetched by the hint, the first viewport remains correct, and the change is useful under the tested conditions. Include one narrow and one wide layout, plus any breakpoint where the image composition changes.

If the hint fails those checks, remove or revise it instead of treating its presence as an optimization requirement. A smaller, understandable loading configuration is easier to keep correct than a collection of exceptions added to silence warnings. The finished repair should explain both which request was improved and why that request belonged to this page.

Related guides