The bottleneck: browsers discover the LCP image late
Much of the time visitors spend waiting on page loads comes down to resource priority: the browser does not know which assets matter most, so it cannot fetch them ahead of less important ones. CMS platforms such as WordPress have tried to steer this, for example with lazy loading of images, but the defaults they apply leave significant room for improvement. Cloudflare, working with Google's Patrick Meenan, examined where that room is and how a small JavaScript snippet running in Cloudflare Workers can exploit it.

Chrome and other browsers typically defer images until the resources in the HTML <head> have finished loading — image loading is "blocked" by rendering. Developers can override that behavior with fetch priority or similar mechanisms, and raising an important image's priority lets it load earlier, which can meaningfully improve Largest Contentful Paint (LCP).
The difficulty is that the browser may not know which image is the LCP image until rendering has already begun. If the LCP element can be identified before the response reaches the browser, its priority can be raised at the server instead of waiting for discovery. Increasing fetch priority indiscriminately does not work, though: it will not help for images that are lazy-loaded (the directives contradict each other) or that are not critical. The goal is to raise priority for images in the viewport, especially the LCP image, while leaving off-screen images lazy-loaded.
Default lazy loading and its contradictions
WordPress 5.5 introduced a default that marks all images carrying an IMG tag and aspect ratios for lazy loading. Plugins and other techniques can boost LCP images, but lazy-loading everything by default while not knowing which image is the LCP one can create artificial delays. WordPress is working on this and has partially addressed it for block themes.
Quantifying the opportunity with HTTP Archive data
To estimate the size of the problem, Cloudflare analyzed the HTTP Archive. Of roughly 22 million desktop pages tested in February 2023, 46% had an LCP element with an IMG tag, so LCP involved an image about half the time. Among those pages, 8.5 million carried the image in the static HTML delivered with the page — a total potential improvement opportunity of approximately 39% of desktop pages in the dataset.
For mobile, of about 28.5 million pages tested, 40% had an IMG tag as the LCP element, and 10.3 million of those had the image in the static HTML — an opportunity in around 36% of mobile pages. Prioritization cannot help lazy-loaded images, and the dataset contained approximately 1.8 million lazy-loaded LCP desktop images and 2.4 million mobile ones. The net opportunity is therefore about 30% of pages whose original HTML holds an LCP image that is not lazy-loaded; a more advanced Worker that strips the lazy-load attribute reaches the additional 9%.
To find which element on a given site is the LCP element, browser developer tools, WebPageTest, or Cloudflare Observatory can be used.
Heuristics for guessing the LCP image
Position in the HTML
Cloudflare examined where LCP images appear in the HTML, lazy-loaded ones included. About 25% of pages had the LCP image as the first image in the HTML (roughly 10% of all pages), and another 25% had it as the second image. A simple rule — "do not lazy-load the first four images," applied in the browser, the CMS, or a Worker — would address approximately 75% of the lazy-loaded LCP image problem. WordPress reached a similar conclusion and removed the default lazy-load attribute from the first image on block themes, but more is possible.
Ignoring small images
Image size offers a second signal: small images are unlikely to be large enough to serve as the LCP element. Testing several thresholds, 10,000 pixels (under 100x100) proved reliable — it skipped few LCP images while avoiding many non-LCP ones. Ignoring images below 10,000px, the first image was the LCP image in approximately 30–34% of cases; including the second raised this to 56–60%. A practical approach is therefore to assign higher priority to the first four "not-small" images.
The Chrome 114 experiment
An experiment in Chrome 114 implements this idea. The browser has prioritization knobs that are not web-exposed, which allows assigning a "medium" priority to images automatically (fetch priority itself exposes only high or low). That moves the boosted images ahead of other images, async scripts, and parser-blocking scripts late in the body, while keeping them below any high-priority requests such as dynamically injected blocking scripts. The experiment varies how many images get the boost (2, 5 and 10), and in one variant lets a single medium-priority image load during Chrome's "tight" mode — while render-blocking head resources load — to increase the chance the LCP image is ready at first paint. Data is still arriving and no ship decision has been made, but early results show LCP improvements across the entire web for all arms of the experiment, though not by large amounts.
Testing the Worker on WordPress
Cloudflare built a test Worker and deployed it on WordPress test sites with Rocket.net, a WordPress hosting platform focused on performance. The Worker boosts the priority of the first four images and removes the lazy-load attribute where present.
export default {
async fetch(request) {
const response = await fetch(request);
// Check if the response is HTML
const contentType = response.headers.get('Content-Type');
if (!contentType || !contentType.includes('text/html')) {
return response;
}
const transformedResponse = transformResponse(response);
// Return the transformed response with streaming enabled
return transformedResponse;
},
};
async function transformResponse(response) {
// Create an HTMLRewriter instance and define the image transformation logic
const rewriter = new HTMLRewriter()
.on('img', new ImageElementHandler());
const transformedBody = await rewriter.transform(response).text()
const transformresponse = new Response(transformedBody, response)
// Return the transformed response with streaming enabled
return transformresponse
}
class ImageElementHandler {
constructor() {
this.imageCount = 0;
this.processedImages = new Set();
}
element(element) {
const imgSrc = element.getAttribute('src');
// Check if the image is small based on Chrome's criteria
if (imgSrc && this.imageCount < 4 && !this.processedImages.has(imgSrc) && !isImageSmall(element)) {
element.removeAttribute('loading');
element.setAttribute('fetchpriority', 'high');
this.processedImages.add(imgSrc);
this.imageCount++;
}
}
}
function isImageSmall(element) {
// Check if the element has width and height attributes
const width = element.getAttribute('width');
const height = element.getAttribute('height');
// If width or height is 0, or width * height < 10000, consider the image as small
if ((width && parseInt(width, 10) === 0) || (height && parseInt(height, 10) === 0)) {
return true;
}
if (width && height) {
const area = parseInt(width, 10) * parseInt(height, 10);
if (area < 10000) {
return true;
}
}
return false;
}
Under test, the first four images moved to the "high" default priority while the fifth stayed "low," and a speed test placed LCP in the "good" range. That single test does not prove the Worker helps in every situation, but the results are promising.

The problem is not specific to WordPress. Site owners can experiment with the Worker, or adapt it to target likely LCP elements more specifically. Cloudflare says it will keep experimenting along similar lines to find a safe network-wide rule that prioritizes images correctly without requiring a Worker.
APO, Snippets and what comes next
Cloudflare's Automatic Platform Optimization (APO) is a WordPress plugin that serves the whole site from Cloudflare's network, improving metrics through caching. It currently cannot prioritize images over other assets or dynamically rewrite HTML, so the techniques described here are not yet part of it. Folding them in is a possible future step but needs thorough testing. Until then, Cloudflare recommends testing the code sample via Snippets and Experiments to measure the impact. Workers and Cloudflare Snippets are the suggested routes for trying the JavaScript, and Cloudflare is asking users to share their results.



