In this article, I will show you how to disable the native lazy loading of images on WordPress websites without using a plugin.
As you know, WordPress by default lazy loads all images to improve page loading speed, even if you are not using any performance plugin. This feature was introduced in the core after the WordPress 5.5 update.
However, lazy loading the first image on the viewport is not good for page speed or user experience. Therefore, it is better to disable native lazy loading in WordPress and use a better plugin that allows you to exclude top images.
There are two ways to disable lazy loading in WordPress:
- Using a custom code snippet
- Using a plugin
1) Disable Lazy Load in WordPress Using Code (Without Plugin)
To disable native lazy loading, add a custom code snippet to your theme’s functions.php file.
For safety, you can use a code manager plugin like WPCode to add different code snippets to your WordPress website.
You can also use any other code manager plugin to add the code snippet. Just click on the “Add snippet” option, as shown in the image below.
Now, add the following PHP code snippet and click the “Activate” button to save the snippet.
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
Now the lazyloading of WordPress will be blocked and images will load immediately on the page.
2) Disable Lazy Load in WordPress Using a Plugin
If you don’t want to use a custom code snippet, you can install a simple plugin for the same purpose. The plugin contains the same code and makes the process easier.
Just install and activate the Disable Lazy Load plugin by Jeff Starr.
Once you have chosen and completed one of the two methods, lazy loading will stop on your WordPress website.
The same line of code is added to your WordPress website to block native lazy loading, regardless of which method you choose.
If you are already using a code manager plugin, you can use method 1. If you want a better solution for lazy loading, you can use plugins like LiteSpeed Cache, Perfmatters, or WP Rocket. (Follow the video tutorial link here.)
I hope this article helps you disable lazy loading on your WordPress website. If you have any doubts, please let me know in the comment section.