Why You Should Avoid Lazy Loading Your Hero Image

don

Lazy loading is a technique used to delay the loading of images until they are needed, which can improve website performance and bandwidth usage. However, it is not recommended to lazy load above-the-fold content, such as the Largest Contentful Paint (LCP) image, as it can slow down LCP timing and make the page appear visually incomplete for longer. This is because the browser may defer the LCP image in favour of other resources, delaying its download. Google's research suggests that lazy loading the LCP image can negatively impact LCP timing. To optimize website speed, tools like GTmetrix and PageSpeed Insights can be used to identify and exclude the LCP image from lazy loading, improving LCP scores and enhancing the user experience.

Characteristics Values
LCP image Largest Contentful Paint image
LCP image lazy loading Delaying the loading of images until they are needed, i.e., viewable in the browser viewport
LCP image lazy loading impact Slower LCP timing, visually incomplete webpage for longer, lower Core Web Vitals scores
LCP image lazy loading fix Excluding the first image from lazy loading, using Optimole or WP Rocket plugins

cypaint

Lazy loading can slow down LCP timing

Lazy loading is a process that delays the loading of images until they are required. This means that images will not load until they are scrolled to or are viewable in the browser viewport. This helps the browser to prioritise other resources that are more important.

However, if lazy loading is applied to above-the-fold content, such as the Largest Contentful Paint (LCP) image, it may slow down the LCP timing. The LCP image is the largest element that first appears on a page and is, therefore, the LCP element. When this image is lazy-loaded, the browser may defer it in favour of other resources, causing the image to take longer to download and appear. This can make the page appear visually incomplete to the user for a more extended period.

Google's research suggests that lazy loading the LCP image can increase the page's LCP timing. To avoid this, it is recommended to exclude the LCP image from lazy loading. This can be done manually by removing the loading="lazy" attribute from the image in the HTML, or by using plugins like WP Rocket or Optimole, which automatically exclude above-the-fold images from lazy loading.

It is worth noting that lazy loading can still be beneficial for images that are out of view when the page loads. By lazy loading these images, you can improve performance and bandwidth usage. However, when it comes to the LCP image, it is generally best to avoid lazy loading to ensure a faster LCP timing and a better user experience.

cypaint

LCP images should be excluded from lazy loading

When it comes to web performance, one of the key metrics to consider is Largest Contentful Paint (LCP). LCP measures the render time of the largest content element in the viewport, which is often an image. To improve LCP timing, it is generally recommended to lazy load offscreen images. However, it is important to exclude LCP images from lazy loading.

Lazy loading is a technique that delays the loading of offscreen images until they are needed, typically when the user scrolls down the page and the image comes into view. This approach helps to prioritize the loading of other resources that are more critical for the initial page render. While lazy loading can improve page performance by reducing the number of image bytes, it can also have a negative impact on LCP timing if applied to above-the-fold content.

When an LCP image is lazy-loaded, the browser may defer its loading in favor of other resources. As a result, the LCP image may take longer to download, leading to slower LCP timing. Additionally, the page may appear visually incomplete to the user for an extended period, affecting their perception of the site's performance. Google's research supports this, indicating that lazy loading the LCP image can lead to longer LCP timing.

To avoid this issue, it is recommended to exclude LCP images from lazy loading. This can be achieved through various methods depending on the platform being used. For example, WordPress users can take advantage of plugins like WP Rocket or Optimole, which automatically detect the LCP image and exclude it from lazy loading. Alternatively, for those using HTML, simply removing the "loading=lazy" attribute from the LCP image tag will ensure it is not lazy-loaded.

By excluding LCP images from lazy loading, you can strike a balance between optimizing page performance and ensuring a fast LCP timing, ultimately providing a better user experience. It is worth noting that while lazy loading can impact LCP timing, it does not necessarily cause slower performance overall. The impact of lazy loading on LCP should be considered in conjunction with other performance metrics to make informed optimization decisions.

cypaint

Use the Optimole plugin to exclude images from lazy loading

Lazy loading is a process that delays the loading of images until they are needed, meaning they will not load until they are scrolled to and are viewable in the browser viewport. While it is recommended to lazy load offscreen images, it is not advised to lazy load above-the-fold content like your Largest Contentful Paint (LCP) image. This is because the browser may defer the LCP image in favour of other resources, potentially slowing down your LCP timing and making your page appear visually incomplete to the user for longer.

One way to address this issue is by using the free Optimole plugin, which offers optimized lazy loading and other image optimization features. Optimole is a versatile tool that can be used to optimize images, but there may be instances when you want to exclude images from optimization or lazy loading, such as with logos, sliders, galleries, or navigation icons.

To exclude images from lazy loading with Optimole, navigate to WP Dashboard > Optimole, open the Settings tab, expand the Advanced accordion, and open the Exclusion panel. Here, you can use the optimizing/lazyload exclusion types to add filters and prevent the lazy loading of essential images. You can also exclude an entire page from lazy loading/optimizing by using the Page URL contains or Page URL matches methods.

Additionally, Optimole provides an optimization exclusion filter, which can be implemented by copying and pasting a code snippet into the plugin's file or the child theme's functions.php file. This allows you to exclude specific images from lazy loading by replacing the sample URL with the one you need.

Another feature of Optimole is the ability to manually skip a specific number of images at the top of each page or enable automatic detection to exclude only those that appear above the fold. This ensures that critical images are visible immediately without delay. However, it is important to note that excluding too many images from lazy loading can reduce performance benefits and slow down overall page load times.

cypaint

Use modern image formats like WebP and AVIF

Modern image formats like WebP and AVIF offer several advantages over traditional formats such as JPEG and PNG.

WebP, developed by Google, is designed to offer better compression and image quality than JPEG. It enables websites to display high-quality images while maintaining fast page loading speeds. WebP supports transparency, animation, and colour profiles, and offers a more efficient compression rate than JPEG and PNG. Lossless WebP images perform better than AVIF, and uncompressed WebP images also take up less space. WebP is widely supported and is compatible with modern browsers, making it a popular choice for web developers and designers.

AVIF, or AV1 Image File Format, is a newer format based on the AV1 video codec. It offers superior lossy compression for photos and text images, with a 10% improvement across the compression range. AVIF delivers enhanced image quality, especially in complex visuals, and provides more accurate colours and better detail. It also supports a wider range of colour depths, resulting in improved colour accuracy and vibrancy. While AVIF is not as widely supported as WebP, it offers smaller file sizes and better compression, making it a good choice for high-quality images with fine details and accurate colours.

When deciding between WebP and AVIF, it's important to consider your specific requirements. If compatibility is a priority, WebP is a better option due to its wider browser support. On the other hand, if you prioritise image quality and smaller file sizes, AVIF might be more suitable, especially for images with intricate details and a broad colour gamut.

To utilise these modern image formats effectively, consider using plugins or services that can automatically convert uploaded images to WebP or AVIF. This can help optimise loading times and enhance the user experience.

When to Remove Tape: Post-Painting Guide

You may want to see also

cypaint

Lazy load images below the fold to reduce network contention

Lazy loading is a technique that defers the downloading of a resource until it is needed, to conserve data and reduce network contention for critical assets. It became a web standard in 2019 and is supported by most major browsers. While lazy loading is generally beneficial, it is not recommended for above-the-fold content, such as the Largest Contentful Paint (LCP) image. LCP is one of the Web Vitals, and improving it can provide SEO benefits.

When lazy loading is applied to above-the-fold content, the browser may defer the LCP image in favor of other resources, causing a delay in the LCP timing and making the page appear visually incomplete to the user for longer. Therefore, it is advisable to lazy load images below the fold to reduce network contention and improve page load speed.

By not lazy loading below-the-fold images, there is less network contention with the LCP image, allowing it to load more quickly. This technique is particularly useful when network connections are poor, as it helps reallocate bandwidth to LCP candidates, enabling them to load and paint faster.

It is worth noting that WordPress added native lazy loading support in version 5.5, which initially caused issues by lazy loading all images, including the LCP image. However, this was addressed in WordPress 5.9, which automatically excludes the first image from lazy loading. To further optimize images, WordPress users can utilize plugins like WP Rocket and Optimole, which offer features such as optimized lazy loading, image compression, and conversion to optimized formats.

In conclusion, lazy loading images below the fold is an effective strategy to reduce network contention and enhance page load speed. By excluding the LCP image from lazy loading and utilizing appropriate tools and plugins, developers can ensure faster loading times and improve the overall user experience.

Frequently asked questions

The LCP image is the largest element that first appears on a webpage. It is a metric from Google's Core Web Vitals.

Lazy loading delays the download of an image until it is near or in the viewport. If lazy loading is applied to the LCP image, the browser may prioritise other resources over the LCP image, causing it to load slowly and affecting the user experience.

You can use the free Optimole plugin, which offers an optimised lazy loading feature. Alternatively, you can manually exclude the image from lazy loading by entering the URL of the image in the "Exclude from Lazy Loading" box in the Perfmatters plugin settings.

GTmetrix checks to see if the LCP image is lazily loaded. If it triggers this audit, you can review the identified LCP element and find a way to disable lazy loading for that image.

You can compress images using lossy or lossless compression and convert them to modern formats like WebP and AVIF. You should also lazy load images below the fold to reduce network contention.

Written by
Reviewed by
Share this post
Print
Did this article help you?

Leave a comment