How to Disable Lazy Loading for Featured Images in WordPress

Why disable lazy loading?

Lazy loading is a great feature that comes with WordPress, but it has some minor issues. One of them is that it delays the loading of the first images on the page, especially the featured images. This can affect the page speed and the user experience, as the first content should be displayed or even preloaded as soon as possible.

What is lazy loading?

Lazy loading is a technique that improves the page speed by loading the images only when they are in the user’s viewport. This reduces the bandwidth and the loading time of the page. For many years, users have used JavaScript and various plugins for WordPress to enable lazy loading.

However, since WordPress 5.5 update, WordPress supports the native web solution that uses a new ‘loading’ attribute on img tags. This provides a consistent user experience without any content shifting.

After this update, WordPress users don’t need to install any extra plugin or JavaScript for lazy loading images in post content.

Drawbacks of lazy loading

Lazy loading has some drawbacks as well as advantages. One of them is that it may conflict with other lazy loading plugins installed. To solve this, you just need to uninstall those plugins, as you already have native lazy loading enabled. [After WP 5.5]

But the real problem is the lazy loading of featured images. You can disable the native lazy loading by adding some code recommended by WordPress developers, but it may not work for featured images only.

Read Also:  How to Protect wordpress with only 2 Security measures?

This can cause SEO and Core Web Vitals issues, as the featured image is often the largest contentful paint (LCP) on the page. The LCP is a metric that measures how long it takes for the main content of the page to be visible to the user. It is an important factor for ranking and user satisfaction. If the LCP is above 2.5 seconds, you may fail to achieve good web vitals stats.

Lazy loading is overall good for your website and blog, but if it is applied to above-the-fold content (like the LCP image), the browser may prioritize other resources over the LCP image. This means that the LCP image may not be downloaded immediately, and the page may appear incomplete to the user for a longer time.

Solution [Without Plugin]

Some users have found a workaround to disable lazy loading for featured images only. It involves a simple code change that adds the ‘eager’ attribute to the ‘loading’ tag, instead of removing the whole code. [Only for featured images]

Here is the code to disable lazy loading only for featured images:

function disable_lazy_load_featured_images($attr, $attachment = null) {
	$attr['loading'] = 'eager';
	return $attr;
}
add_filter('wp_get_attachment_image_attributes', 'disable_lazy_load_featured_images');

Just paste this code into your ‘functions.php’ file of your theme. And you are done.

If you are not using a child theme, I recommend installing the DLLFI Plugin, which can disable the lazy loading for featured images without altering the ‘functions.php’ file.

DLLFI [WordPress Plugin]

This plugin helps to disable the lazy loading feature for featured images.

DLLFI: Disable Lazy loading

How to use this plugin

This plugin lets you disable the WP Lazy Loading feature (introduced in WP version 5.5) for Featured Images only. To turn it back on, just deactivate the plugin.

Read Also:  How to make a fast loading online store with wordpress

Benefits of this plugin

* It is very simple and efficient – it only adds one line of code.
* It solves the core web vitals issue of lazy loading the first image on the page. [Featured Image]
* It allows you to keep the lazy loading for the rest of the images.

Why do you need this plugin?

This plugin helps you optimize your website’s SEO and user experience by disabling the lazy loading for featured images only. Lazy loading the first content on the page can make your website appear slower and incomplete to the user.

By using this plugin, you can avoid this problem without modifying any functions.php codes.

After activating this plugin, you will notice the difference in your website’s performance and appearance. I also recommend you to check out my ‘WordPress Pro’ plugin that offers more solutions and enhancements for your website.


• Behind the scenes
• Bloopers & stuffs
• Early access to my works
• More fun...

2 Comments

  1. Can you include the link to your ‘WordPress Pro’ Plugin that fixes core web vitals as you mentioned in the blog?

    • I am sorry to say that ‘wordpress pro’ plugin has been deprecated due to compatibility issues. Currently we are working on a plugin alike we would announce later.

Leave a Reply

Your email address will not be published. Required fields are marked *