How to disable lazy loading featured images in wordpress

Disable lazy loading?

You may be wondering why disabling such a great feature comes pre-made with wordpress? It is because of the minor issues of native lazy loading such as lazy loading of first images displayed.

Especially featured images shouldn’t be lazy loaded like rest of the images, which will impact the loading of a web page and result in slow loading of first content. As you know, first content should be displayed or even preloaded for better user experience.

Lazy Loading

Lazy Loading images in the blog posts or in a website is a page speed improving mechanism that is used by many for years. For enabling lazy load, users has been used javascript and variety of plugins for WordPress which enables the magic.

Recently [After WordPress 5.5 Update] WordPress enables the native web solution which relies solely on the presence of a new ‘loading’ attribute on img tags and provides a standardized user experience without content shifting.

After this update, WordPress users don’t have to install an extra plugin or additional javascript for lazy loading images in post content.

Drawbacks of Lazy Load

There are fewer drawbacks to this type of lazy loading as well as advantages. The native lazy loading may conflict with other lazy loading plugins installed.

For solving those, you just need to uninstall those plugins, because you already have lazy loading enabled natively. [After WP 5.5]

Read Also:  Why Bluehost remains the most reliable wordpress hosting

But the real problem is not those, It is the lazy loading of featured images. Usually you can disable the native lazy loading by adding few codes recommend by WordPress developers.

But still the code doesn’t work for featured images or featured images only.

There are SEO and Core Web Vitals problems in lazy loading the images on the first paint, which means the featured image.

Your Google page speed score and user experience will also be effected by this problem, and this lead to lower page speed, lower Google search ranking as the largest contentful paint was lazy loaded.

Core Web Vitals became the important factor for ranking and always better for user experience and if the LCP is above 2.5 seconds, you are failed to achieve good web vitals stats.

Lazy loading is overal good for your website and blog, but If however, lazy loading is applied to above-the-fold content (like the LCP image), the browser may lazy load the LCP image in favour of other resources.

As the LCP image is not immediately downloaded, it may slow down your LCP and make your page appear not complete to the user for a longer period of time.

Solution [Without Plugin]

Some users complained that using the WordPress recommended option to disable lazy loading for featured Images doesn’t work, There is a workaround.

We are getting things done by a simple code change that implementing ‘eager’ attribute to the ‘loading’ tag instead of removing complete 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 on to your ‘functions.php’ of your theme. And get rid of this problem.

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

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’

DLLFI [WordPress Plugin]

This plugin helps to Disable Lazy Loading feature for Featured Images.

DLLFI: Disable Lazy loading

Activate this plugin to disable the new WP Lazy Loading functionality (added in WP version 5.5) For Featured Images. To re-enable lazy loading [For Featured Images] at any time, simply deactivate the plugin.

Features of Plugin

* Lightweight – only one line of code.
* Fix core web vitals issue of lazy loading first image. [Featured Image]
* Disable lazy loading only for featured images.

Why is this useful?

Because this plugin disables the current wordpress lazy loading only for featured images. Lazy loading on the first displayed contents are very bad for your website’s seo and users experience.

By Enabling this plugin, you can easily get things done without altering any functions.php codes.

After activating this plugin, I completely get rid of the problem and I recommend you to install this plugin or my ‘WordPress Pro’ plugin that addresses most of the Core problems and Performance fixes.

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 *