Image Preload Hints
Issue No: 115
Category: Resource Hints & Performance Issue Type: Issue Priority: Important
Description
Pages with above-fold images should declare <link rel="preload" as="image"> tags so the browser fetches those images at high priority during HTML parsing, reducing render latency for critical visual content.
Crawler Constraint: The XeoPix crawler can detect
<link rel="preload" as="image">tags in raw HTML and count<img>elements. It cannot determine which specific image is the LCP element — that requires browser rendering and layout measurement. The trigger fires when the page contains<img>elements but declares no image preload hint.
How Do We Capture It
Where to Find
Inside HTML <head>:
<link rel="preload" as="image" href="/images/hero.webp">
<!-- With responsive image support -->
<link rel="preload"
as="image"
href="/images/hero-800.webp"
imagesrcset="/images/hero-400.webp 400w, /images/hero-800.webp 800w"
imagesizes="100vw">
HTML Extraction Flow
The XeoPix crawler downloads the raw HTML response and parses the <head> block:
- Issues an HTTP GET to the target URL.
- Reads raw response bytes without JavaScript execution.
- Scans the
<head>block for all<link rel="preload">tags. - Filters for tags where the
asattribute equalsimage. - Extracts the
href,imagesrcset, andimagesizesattributes from each matched tag. - Records the count and full list of preloaded image URLs.
Validation Logic
The crawler validates:
- Whether any
<link rel="preload" as="image">tag exists. - Whether the
hrefis a valid non-empty URL.
How to Get It
Crawler should:
- Parse raw HTML
<head>. - Find all:
link[rel="preload"][as="image"]. - Extract
href,imagesrcset,imagesizesfrom each. - Count and store all matched entries.
What to Store
| Field | Type | Comment |
|---|---|---|
has_image_preload | BOOLEAN | Whether any image preload link tag is declared in the page head |
preload_image_hrefs | TEXT[] | Array of image href values declared in preload tags |
preload_image_count | INT | Number of image preload link tags found on the page |
preload_image_has_srcset | BOOLEAN | Whether any image preload tag declares an imagesrcset attribute for responsive images |
img_total_count | INT | Total number of img elements found in the page HTML |
has_imgs_and_no_image_preload | BOOLEAN | Whether the page has img elements but no image preload hint declared in the head |
Condition for Trigger
The following trigger rule fires only when the page contains img elements but no image preload hint is declared.
- Trigger Rule 1: Page Has Images But No Image Preload Hint
- Target Field:
has_imgs_and_no_image_preload - Evaluation Logic:
= TRUE - Severity: WARNING
- Diagnostic Message: "This page contains img elements but declares no image preload hint. Above-fold images benefit significantly from a preload hint, which instructs the browser to fetch the image at the highest priority during HTML parsing rather than waiting until the render tree is built."
- Target Field:
Sources
- MDN — link rel=preload
- web.dev — Preload critical assets
- Google Search Central — Optimize Largest Contentful Paint (LCP)
- web.dev — LCP optimization guide
- W3C Preload specification
Long Description
The Largest Contentful Paint (LCP) metric measures how long it takes for the largest visible element in the viewport to fully render. For most pages, the LCP element is a hero image displayed above the fold. Google uses LCP as a Core Web Vital — a ranking signal in Search.
Without an image preload hint, the browser's typical image discovery sequence is:
- Browser downloads and parses the HTML.
- Browser encounters a
<link rel="stylesheet">and downloads the CSS. - CSS is parsed; browser discovers
background-image: url(hero.webp)in the CSS. - Only now does the browser request the hero image.
This late discovery adds a full CSS download + parse round trip before the LCP image begins downloading — directly harming LCP time.
With <link rel="preload" as="image"> in <head>:
- Browser begins parsing HTML.
- Immediately on discovering the preload tag, the browser queues a high-priority fetch for the image.
- The image download begins in parallel with CSS and other resources.
- By the time rendering reaches the LCP element, the image is already downloaded or close to it.
Responsive image preloading:
For pages using <picture> or srcset, the imagesrcset and imagesizes attributes on the preload tag tell the browser which image variant to preload based on viewport width:
<link rel="preload"
as="image"
href="/images/hero-800.webp"
imagesrcset="/images/hero-400.webp 400w, /images/hero-800.webp 800w"
imagesizes="100vw">
Common failure scenarios:
1. Hero Image in CSS Background Without Preload
The LCP image is set as a background-image in CSS. Without a preload hint, the browser cannot discover the image until the CSS is fully downloaded and parsed.
2. Hero Image in HTML Without Preload
<!-- Image discoverable from HTML but still benefits from preload -->
<img src="/images/hero.webp" alt="Hero">
Even when an image is in the HTML, without a preload hint it competes equally with all other resources. The preload hint elevates it to the highest fetch priority.
3. Hero Image Loaded via JavaScript
If the image is injected by JavaScript, the crawler cannot capture it. This is a known constraint — the preload hint must still be declared in the HTML <head> to be effective.
4. Preload Declared for Wrong Image
A preload hint exists but points to a decorative image, not the LCP hero. The crawler cannot detect this without browser rendering.
How to Fix
Add a <link rel="preload" as="image"> tag for the hero image in the page <head>:
<!-- For a single hero image -->
<link rel="preload" as="image" href="/images/hero.webp">
<!-- For responsive hero images -->
<link rel="preload"
as="image"
href="/images/hero-800.webp"
imagesrcset="/images/hero-400.webp 400w, /images/hero-800.webp 800w"
imagesizes="(max-width: 600px) 400px, 800px">
Guidelines:
- Only preload the single most critical above-fold image (the LCP element).
- Do not preload multiple images — this dilutes the priority benefit.
- Match the
hrefto the exact URL the browser would request (same format as thesrcorsrcset). - Place the preload tag as early as possible in
<head>, before any render-blocking resources. - If the image format is WebP or AVIF, include a
typeattribute:type="image/webp".