Support » Fixing WordPress » How to disable global lazy loading?

  • basshead

    (@basshead)


    From my understanding after WordPress 5.4 or 5.4.1 lazy loading was added in by default to its core files. I noticed that most of my images load only after scrolling. I know that this is a performance feature but I am looking to disable it globally on my site and I am not sure how. Any help would be appreciated.

    https://make.wordpress.org/core/2020/01/29/lazy-loading-images-in-wordpress-core/

    This is the issue but I am uncertain how to implement this on my website globally. It says a filter can be added but I do not have any experience with this or know how to make a plugin. I can not find any plugins that provide this option to disable.

    • This topic was modified 5 months ago by basshead.
    • This topic was modified 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
    • This topic was modified 4 months, 3 weeks ago by Jan Dembowski.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    It’s right in the page you linked:

    A new filter wp_lazy_loading_enabled will allow turning the feature on and off. For example, one could disable lazy-loading entirely with the following snippet:

    add_filter( ‘wp_lazy_loading_enabled’, ‘__return_false’ );

    Add that line to your theme’s functions.php or make a quick plugin and drop it into wp-content/plugins

    <?php
    /**
     * Plugin Name: Disable Core Lazy Load 
     * License: Gnu Public License V2
     * License URI: http://www.gnu.org/licenses/gpl-2.0.html
     */
    
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    add_filter( 'wp_lazy_loading_enabled', '__return_false' );
    

    Note: I have not tested this code. Use at your own risk.

    basshead

    (@basshead)

    Thank you for the extra information!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.