Check 06.18 · Performance and Core Web Vitals

Optimize the LCP image without lazy loading

Make the LCP image load first: an img tag in the HTML, no lazy loading, fetchpriority high, with the code for each common CMS and framework.

Priority
Important
Difficulty
Intermediate
Estimated time
1 to 3 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

On most pages, the largest element visible at load time is an image: header visual, product photo, article illustration. This is what determines the LCP (Largest Contentful Paint). This check consists of making sure the browser discovers it as soon as it reads the HTML, downloads it with priority and waits for nothing before displaying it: an <img> tag in the initial HTML, without loading="lazy", with fetchpriority="high", in a suitable format and size.

Why it matters

The display time of the LCP image breaks down into four phases:

Phase What happens What lengthens it
Time to first byte (TTFB) the server produces the HTML hosting, database, redirects
Load delay the browser has not yet started the image request lazy loading, image in CSS or injected by JavaScript, low priority
Load duration the image is in transit weight, format, connection to another domain
Render delay the image is there but not displayed blocking CSS or scripts, fade-in animation

This guide mainly covers the second phase, the one most often wasted:

  • loading="lazy" on the main image: the browser waits until it has computed the layout to know whether the image is on screen, and so until it has downloaded and applied the CSS. The request starts late.
  • Background image in CSS, or inserted by a carousel script: it does not exist in the HTML. The browser can only request it after loading the CSS or running the script.
  • Default priority: images start with low priority and are only promoted once the layout is known. The fetchpriority="high" attribute removes this wait.

What it improves

  • LCP This is the most direct action on this metric when the main element is an image. See target LCP ≤ 2.5 s at the 75th percentile (opens in a new tab).
  • Perceived speed The main visual appears early, even if the rest of the page keeps loading.
  • Image indexing An <img> tag with src in the HTML is the format Google recommends for discovering images. A useful side effect, not a ranking factor.
  • Rankings Indirect effect, through Core Web Vitals.

How to check

Identify the LCP element. In the console, on the loaded page:

new PerformanceObserver((list) => {
  const entry = list.getEntries().at(-1);
  console.log('LCP:', Math.round(entry.startTime), 'ms', entry.element, entry.url);
}).observe({ type: 'largest-contentful-paint', buffered: true });

PageSpeed Insights also identifies the LCP element and details its four phases. See analyze PageSpeed Insights and Lighthouse (opens in a new tab). Test on both mobile and desktop: the element is not always the same.

Check its tag in the initial HTML (not in the DOM after the scripts have run):

curl -s https://example.com/ | grep -o -i -E '<img[^>]*>' | head -n 5

Compliant result: the LCP image appears in this output, with a real src (not a data-src or a placeholder image), without loading="lazy", with fetchpriority="high".

Check the waterfall. In the Network tab, “Priority” column, the image should have high priority from the start and its request should begin right after the HTML request, without waiting for a script.

How to implement

Before you start

Target tag, for a full-width header image:

<img src="/images/hero-1200.webp"
     srcset="/images/hero-600.webp 600w, /images/hero-1200.webp 1200w, /images/hero-2000.webp 2000w"
     sizes="100vw"
     width="1200" height="600"
     alt="Workshop seen from the entrance"
     fetchpriority="high">

Rules that apply everywhere:

WordPress

Versions WordPress 6.3 and later (up to 7.1).

Since version 6.3, WordPress itself adds fetchpriority="high" to the first large image in the content and removes loading="lazy" from it. Check that this detection gets it right on your templates: a logo, a banner or a page builder can mislead it.

To force the behavior in a theme template:

the_post_thumbnail('large', [
    'loading' => 'eager',
    'fetchpriority' => 'high',
]);

To change the number of content images that WordPress excludes from lazy loading:

add_filter('wp_omit_loading_attr_threshold', function (): int {
    return 1;
});

With an optimization plugin, script-based lazy loading is added on top of WordPress's and often applies to the main image:

  • WP Rocket: recent versions automatically detect and exclude above-the-fold images. For a manual exclusion, add the data-no-lazy="1" attribute to the tag or enter the file in the exclusions of the Media tab.
  • LiteSpeed Cache: Page Optimization > Media Settings, lazy load exclusion field.
  • Perfmatters: options to exclude the first images and to preload critical images, in the lazy loading settings.
  • Elementor, Divi and other builders: a section with a background image produces a CSS background. For the main visual, prefer an image widget, or disable background lazy loading for that section.

Purge the cache after each setting change, then check the HTML again with curl.

Shopify

Versions Online Store 2.0 themes, all Shopify plans, November 2026.

The image_tag filter adds loading="lazy" to images in sections located further down the page. For the main image, set the attributes yourself:

{{ section.settings.image
  | image_url: width: 2000
  | image_tag:
    widths: '600, 1200, 2000',
    sizes: '100vw',
    loading: 'eager',
    fetchpriority: 'high' }}

For a section reused in several places, decide based on its position:

{%- if section.index == 1 -%}
  {%- assign image_loading = 'eager' -%}
  {%- assign image_priority = 'high' -%}
{%- else -%}
  {%- assign image_loading = 'lazy' -%}
  {%- assign image_priority = 'auto' -%}
{%- endif -%}

{{ section.settings.image | image_url: width: 2000 | image_tag: loading: image_loading, fetchpriority: image_priority }}

On the product page, apply the same logic to the first image of the gallery (forloop.first). Check the HTML output: the image_tag documentation does not cover fetchpriority, which is passed through as a free HTML attribute.

PrestaShop

Versions PrestaShop 8 and 9, Classic theme.

The Classic theme puts loading="lazy" on all its images, including those visible at load time. In a child theme:

  • Product page: templates/catalog/_partials/product-cover-thumbnails.tpl. Remove loading="lazy" from the cover image (js-qv-product-cover class) and add fetchpriority="high".
  • Product lists: templates/catalog/_partials/miniatures/product.tpl. Only keep lazy loading from the second row onwards, based on the position passed to the template.
  • Home slider: override modules/ps_imageslider/views/templates/hook/slider.tpl in your theme. For the first slide ({if $smarty.foreach.homeslider.first}), replace loading="lazy" with fetchpriority="high".

The Hummingbird theme, shipped with PrestaShop 9, has its own templates: apply the same logic to the cover image and the first slide.

Clear the cache in Advanced Parameters > Performance.

Magento

Versions Magento Open Source and Adobe Commerce 2.4.4 to 2.4.9, Luma and Blank themes.

Two cases to check in the initial HTML:

  • Product page: the gallery is built in JavaScript. The template inserts a placeholder image (gallery-placeholder__image) in the HTML so that the main image is discovered early. Override Magento_Catalog/templates/product/view/gallery.phtml in your theme to add fetchpriority="high" to it.
  • Category pages and Page Builder blocks: thumbnails can carry loading="lazy" even on the first row, and Page Builder banners use CSS backgrounds. Fix the thumbnail template in the theme, and preload the main banner.

The Hyvä theme exposes these settings more directly; refer to its documentation.

Drupal

Versions Drupal 10 and 11.

Drupal adds loading="lazy" to images whose dimensions are known. For the main image field, open Structure > Content types > your type > Manage display, click the field's gear icon and set the image loading attribute to “Eager”. To add the priority, in montheme.theme:

function montheme_preprocess_image(array &$variables): void
{
    if (($variables['attributes']['loading'] ?? null) !== 'eager') {
        return;
    }

    $variables['attributes']['fetchpriority'] = 'high';
}

This code assumes that only one image per page is set to “Eager”.

Wix

Versions Wix Editor and Wix Studio, all plans, November 2026.

Image loading is handled by the platform, with no per-image setting. Your levers are editorial: a still image rather than a slideshow or a video at the top of the page, and no entrance animation on the first screen. The same applies to Squarespace.

Webflow

Versions Webflow Designer, all plans, November 2026.

Select the main image, open its settings and change the loading option from “Lazy” (the default) to “Eager”. Use an Image element rather than a section background image.

Laravel

Versions Laravel 10 to 13.

The Blade template writes the target tag as is. In a list, only the first image gets priority and lazy loading only starts after the first row:

@foreach($products as $product)
    <img src="{{ $product->image_url }}"
         width="400" height="400"
         alt="{{ $product->name }}"
         @if($loop->first) fetchpriority="high" @elseif($loop->index >= 4) loading="lazy" @endif>
@endforeach

Symfony

Versions Symfony 6.4 to 8.1, Twig 3.

Same logic in Twig:

{% for product in products %}
    <img src="{{ product.imageUrl }}"
         width="400" height="400"
         alt="{{ product.name }}"
         {% if loop.first %}fetchpriority="high"{% elseif loop.index0 >= 4 %}loading="lazy"{% endif %}>
{% endfor %}

Next.js

Versions Next.js 15 and 16 (App Router and Pages Router).

The next/image component lazy-loads images by default. For the LCP image:

import Image from 'next/image';
import hero from './hero.jpg';

export default function Hero() {
  return (
    <Image
      src={hero}
      alt="Workshop seen from the entrance"
      sizes="100vw"
      loading="eager"
      fetchPriority="high"
    />
  );
}

Since Next.js 16, the priority prop is deprecated: use loading="eager" with fetchPriority="high", or preload if you also want a preload tag in the <head>. On earlier versions, priority does both.

Nuxt

Versions Nuxt 3 and 4, Nuxt Image module 1.x and 2.x.

With the Nuxt Image module:

<NuxtImg
  src="/images/hero.jpg"
  width="1200"
  height="600"
  sizes="100vw"
  format="webp"
  alt="Workshop seen from the entrance"
  loading="eager"
  fetchpriority="high"
  preload
/>

Check that the image is rendered on the server: a component wrapped in <ClientOnly> does not appear in the initial HTML.

Astro

Versions Astro 5.10 and later (up to 7); manual attributes before 5.10.

The Image component outputs loading="lazy" by default. Since Astro 5.10, the priority prop applies loading="eager", decoding="sync" and fetchpriority="high" in one go:

---
import { Image } from 'astro:assets';
import hero from '../assets/hero.jpg';
---
<Image src={hero} alt="Workshop seen from the entrance" priority />

On an earlier version, write the loading="eager" and fetchpriority="high" attributes yourself.

Cloudflare

Versions Cloudflare dashboard, all plans (Polish from the Pro plan), November 2026.

No setting replaces fixing the template, but two features help: automatic conversion to WebP or AVIF (Polish or image transformations, depending on the plan) shortens the download time, and Early Hints (opens in a new tab) bring the request forward if your origin sends a preload Link header for the image.

Warning: CDN or plugin features that replace src attributes with placeholder images loaded by JavaScript apply to every image, including the main one. Exclude it explicitly.

Common mistakes

  • Leaving loading="lazy" on the main image because the component or the CMS adds it by default.
  • Putting fetchpriority="high" on every image in the first screen: only one should have it.
  • Keeping the main visual as a CSS background without preloading.
  • Loading the first slide through the carousel script: it waits for the library to be downloaded and executed.
  • Fading the image in from zero opacity: as long as it is invisible, it does not count, and the LCP is delayed accordingly.
  • Serving mobile visitors the image intended for a large screen, for lack of correct srcset and sizes.
  • Preloading a URL different from the one the tag will request: two downloads instead of one.
  • Only testing the home page: the article, category and product templates each have their own LCP element.

Frequently asked questions

Should I put loading="lazy" on the main image?

No. With loading="lazy", the browser waits until it has computed the layout, and so until it has downloaded and applied the CSS, to know whether the image is on screen: its request starts late and the LCP slips. The main image should be an img tag present in the initial HTML, with no lazy loading at all, native or script-based, and it should carry the fetchpriority="high" attribute.

What is fetchpriority="high" for?

By default, images start with low priority and are only promoted once the layout is known. The fetchpriority="high" attribute asks the browser to download the image with high priority as soon as it discovers it in the HTML, which shortens the display delay of the LCP image. Put it on a single image per page: put everywhere, it no longer prioritizes anything.

How do I know which image is the LCP element?

PageSpeed Insights identifies the LCP element and details its four phases. In the browser console, a PerformanceObserver of type largest-contentful-paint also shows the element and the image URL. Test on mobile and desktop, as the element is not always the same, and on every template: home, article, category and product pages each have their own.

Updated on

Topic checklist (PDF)

And now?

In the “Performance and Core Web Vitals” topic

  1. Analyze PageSpeed Insights and Lighthouse
  2. Analyze real-user CrUX data
  3. Target LCP ≤ 2.5 s at the 75th percentile
  4. Target INP ≤ 200 ms at the 75th percentile
  5. Target CLS ≤ 0.1 at the 75th percentile
  6. Target TTFB ≤ 800 ms as a benchmark
  7. Optimize hosting and CDN
  8. Enable Brotli/Gzip
  9. Configure browser and server caching
  10. Minify CSS and JavaScript
  11. Remove unused CSS/JS
  12. Reduce render-blocking resources
  13. Defer non-essential scripts
  14. Limit third-party scripts
  15. Optimize database queries
  16. Optimize fonts (WOFF2, font-display)
  17. Preload only critical resources
  18. Optimize the LCP image without lazy loading
  19. Lazy-load offscreen content
  20. Reserve space for media and ads
  21. Reduce DOM complexity
  22. Test before and after cookie consent
  23. Test on a slow mobile connection
  24. Set a performance budget
  25. Preload likely navigations with Speculation Rules
  26. Make pages eligible for the back/forward cache (bfcache)
  27. Diagnose INP with Long Animation Frames (LoAF)