How to disable WordPress lazy loading

Another new feature that WordPress 5.5 brought us was the native lazy loading of images, a technique that makes the images only load as you navigate the page, thus avoiding unnecessary consumption and loading delays in the browser.

However, although it is normally a good practice, you will not always want WordPress native lazy loading to be active, for different reasons:

  • You don’t want to use this WPO technique for your own reasons.
  • You already use another system (plugin, theme, etc.) to perform the deferred loading.

If you are in any of these cases, keep reading, if you are not, spend your time wisely as you most like.

Disable WordPress native lazy loading completely

If you want to, disabling the native WordPress lazy loading of all images is very easy.

With code

You can add this filter to your utility plugin:

add_filter( 'wp_lazy_loading_enabled', '__return_false' );Code language: JavaScript (javascript)

Save the changes and you’re done, native lazy loading is now disabled.

A more “elegant” way would be to do it through a custom function, so that you can add it to a plugin, or create a plugin just for that. Then the code would be like this:

function wphelp_disable_image_lazy_loading( $default, $tag_name, $context ) {
return false;
add_filter('wp_lazy_loading_enabled', 'wphelp_disable_image_lazy_loading', 10, 3);Code language: PHP (php)

With plugins

Now, if you prefer to use plugins, you have a couple of possibilities…

With Disable Lazy Load, once activated, you have settings to decide whether to disable lazy loading on all images or only on thumbnails.

This other one, however, simply applies the filter we have seen before, so it is activated and ready, with no options.

Disable native lazy loading on certain attachment types only

If you prefer a little more control, you can specify what type of attached images to disable deferred loading, as in this example code:

//Disable native lazy loading by ID and size of attachment
function wphelp_without_lazy_loading_id( $value, $image, $context ) {
if ( 'the_content' === $context ) {
$image_url = wp_get_attachment_image_url( 100, 'large' ); // Change ID and size of attachment
if ( false !== strpos( $image, ' src="' . $image_url . '"' ) {
return false;
return $value;
add_filter( 'wp_img_tag_add_loading_attr', 'wphelp_without_lazy_loading_id', 10, 3 );Code language: PHP (php)

This code disables deferred loading on the large image size with ID 100.

Disable WordPress native lazy loading with optimization plugins

settings lazy loading sg optimizer

The other possibility is that, if you already use an optimization plugin that contemplates the delayed loading of images, it will previously deactivate the native WordPress functionality of lazy loading.

Of the most recommended ones, and which I usually use both in my sites and those of my clients, the following plugins have already been updated to disable WordPress native lazy loading and prioritize theirs, usually more granular and customizable:

What is the most recommendable?

Image lazy loading mobile

The delayed loading of media (images, video, etc.), not just images, is strongly recommended as it is a very effective optimization and performance technique for…

  • Avoid delays in page loading.
  • Consume less hosting resources.
  • Save bandwidth.
  • Save battery in mobile devices.
  • A fast browsing experience.

So it is not optional, it is in my point of view a mandatory WPO optimization technique.

But is it better to use WordPress native deferred loading or another?

Well, right now, as long as it doesn’t incorporate more control over deferred loading and the possibility of applying it to other media besides images (video, Gravatars, shortcodes, widgets, etc.) I don’t recommend WordPress native lazy loading because it’s too basic.

It is much better to disable it and use some system (code or plugin) that does allow you to defer loading other media.

Read this post in Spanish: Cómo desactivar la carga diferida (lazy load) de imágenes de WordPress

How useful was this post?

Click on a smiley to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

1 thought on “How to disable WordPress lazy loading”

  1. Hey Hector,

    is it possible to define an offset of images which not get the lazy loading attribute?
    For example, all images in view should be not lazy loading (first 4 of images for example) all others shall lazy load.

    I’ve seen that kind of functionality in plugins, but I prefer to use a code snippet instead. Can you help with that?

    Best regards,

Leave a Comment

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

Scroll to Top