Skip to content
FunnelGuard

Fix guide by FunnelsGuard

LCP image loaded by a JavaScript slider: how to fix it

PRF-009Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Largest Contentful Paint (LCP) is the time until the biggest visible element in the first screen has been drawn. On many landing pages that element is the hero image.

Many sliders (carousels) ship an empty container in the HTML. Their JavaScript then downloads, reads its settings, creates the img or a CSS background and starts the image download. The browser's preload scanner, which finds images while the HTML is still loading, cannot see any of that. So the image request starts late.

How a JS-injected slider image arrives
  1. HTML arrivesEmpty slider container, no img tag
  2. Slider JS downloadsOften a large, render-blocking file
  3. JS builds slideImage URL is only known now
  4. Image downloadsRequest starts late
  5. LCP paintedVisitor sees the hero late

The image request cannot start until the slider script has run.

Why it costs you leads or sales

Visitors from ads judge a landing page in seconds. If the main image and headline area stay empty or jump around, some leave before they see your offer or form. You also pay for those clicks. A slow LCP can also weigh on your Core Web Vitals results, which Google uses as a page experience signal.

LCP by hero setupExample numbers
LCP by hero setup (example)Slider injects image with JS: 4.2 seconds; First slide in HTML: 2.6 seconds; First slide in HTML + preload: 1.9 seconds0234.22.61.9Slider injects image …First slide in HTMLFirst slide in HTML +…seconds

Example: illustrative LCP times for the same page with different hero setups. Your numbers will differ.

How to check if your site has it

Confirm the slider creates your LCP image
  1. View the page source

    Open the page, right-click and choose View page source (not Inspect). Search for the hero image file name. If it is missing from the source, JavaScript adds it later.

  2. Find the LCP element

    Run PageSpeed Insights on the URL. Under Diagnostics, open Largest Contentful Paint element. It shows the exact element and the phases of the load.

  3. Look at resource load delay

    In Chrome DevTools, open Performance, record a reload and click the LCP marker. A long gap before the image request (resource load delay) points to late discovery.

  4. Test on mobile

    Repeat with mobile throttling. Slider scripts hurt most on slower phones and networks.

How to fix it

The goal is that the browser can see the first image in the raw HTML. The simplest fix is a single static hero image. If you need a slider, make only the first slide static and load the rest later.

First slide as real HTML, with priorityhtml
<link rel="preload" as="image" href="/img/hero-1.webp" fetchpriority="high">

<div class="slider">
  <img src="/img/hero-1.webp" width="1200" height="600"
       alt="Describe the offer" fetchpriority="high">
</div>

<script src="/js/slider.js" defer></script>
Fix by platform
  1. Replace or reconfigure the slider

    If the hero does not need to move, swap the slider block for a single Image or Cover block. Otherwise check your slider plugin's settings for options such as server-side first slide, lazy load off for the first slide, or a static fallback image. Option names vary by plugin.

  2. Exclude the hero from lazy loading

    If your optimisation plugin delays JavaScript or lazy-loads images, exclude the slider script and the first image from those features, then retest.

How to confirm it's fixed

After the change
  • The hero image file name now appears in View page source
  • PageSpeed Insights shows the LCP element as a normal img with no long resource load delay
  • The image request starts early in the DevTools Network panel
  • LCP on mobile is lower than before (compare several runs, as results vary)
  • The slider still works and the other slides still appear
  • Layout does not jump when the slider starts

How to prevent it happening again

Habits that keep it fixed
  • Treat the first screen as static: no JavaScript should be needed to show it
  • Ask for a performance check before adding a new slider or page builder widget
  • Re-test LCP after theme, plugin or optimisation setting changes
  • Check that delay-JavaScript features exclude the hero
  • Keep hero images compressed and close to their displayed size
  • Review key landing pages in PageSpeed Insights each month

How FunnelGuard handles this

FunnelGuard detects this issue only partly. It detects the LCP time on your funnel steps when the robot visitor runs them on a schedule. It does not detect the cause, so it cannot tell you that a JavaScript slider is the reason the image is late.

To cover the rest by hand: when FunnelGuard flags a slow LCP, open the page, view the source, and search for the hero image file name. Then run PageSpeed Insights and read the LCP element and its timing breakdown. If the image is missing from the source, follow the fixes above. You can start with the Free plan (1 site, 2 journeys, daily checks, no card), and paid plans include a 3-day free trial.

Questions people ask

Why is my slider image slow to load?

Many sliders create the first image with JavaScript. The browser cannot start downloading it until the script has loaded and run, so the image appears late. Putting the first slide in the HTML as a normal img tag removes that delay.

Does a hero slider hurt LCP?

It can. If the slider injects its first image with JavaScript, lazy-loads it, or blocks rendering with a heavy script, LCP gets worse. A slider that outputs the first slide in HTML and loads its script with defer has much less impact.

How do I find out if JavaScript is adding my LCP image?

Use View page source and search for the hero image file name. If it is not there, JavaScript adds it later. PageSpeed Insights also shows the LCP element and how long the browser waited before starting its download.

Should I remove my homepage slider?

Often yes, for the first screen. A single static hero image is faster and usually clearer for visitors. If you keep a slider, make slide one static HTML, preload it and load the other slides later.

Should the first slide have loading=lazy?

No. The first visible slide is usually the LCP image, and lazy-loading delays it. Use loading=eager and fetchpriority=high on that image, and lazy-load only slides that start off-screen.

Can FunnelGuard tell me my slider causes slow LCP?

Not fully. FunnelGuard detects the LCP time on your funnel steps, but not the cause. You need to check the page source and PageSpeed Insights by hand to see whether a slider injects the image.

Will preloading the image fix a slider problem?

A preload link can help the browser fetch the image early, but the image must still be shown quickly. It works best together with the first slide as real HTML and a deferred slider script. Preload only the exact file and size used.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: LCP time detected, cause not.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.