• Resolved Web Guys

    (@webinfinitynz)


    Hi,

    I have a few questions;

    1. Does this plugin have an option to lazy load on mobiles only?
    (I hate lazy load of desktops but think I need it for mobiles)

    2. Can it lazy load HTML5 <video> ?
    (I have various video backgrounds, which use the <video> element)

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor WP Rocket

    (@wp_rocket)

    Hi,

    1) There isn’t an option for that, but it could be done programmaticaly with the following code:

    add_filter( 'do_rocket_lazyload', function() {
        if ( ! wp_is_mobile() ) {
    	return false;
        }
    
        return true;
    } );

    What it does is check if the current device is a mobile device as identified by the wp_is_mobile() function, and if it isn’t, it’s preventing lazyload from being applied. If it’s a mobile device, lazyload is applied.

    2) Currently it supports iframes, images and picture elements. Video elements are not yet supported.

    Thread Starter Web Guys

    (@webinfinitynz)

    Thanks for the reply and info.

    Can you please pass these 2 suggestions onto your devs, for possible implementation into your plugin?

    I feel both would add valuable features.

    1. I (and I think a good % of people) don’t like lazy loading on desktops. Most of my sites just don’t need it and it reduces the user experience.
    But for phone on a 3G or 4G, I can definitely see some use for it.
    I toggle in the plugin options to only apply the lazy load to phones, using that code, would be great for a lot of users.

    2. Regarding <video>, I think more web designers are using html5 videos now. So it would be great if we had the option to lazy load those as well.

    Anyway, thanks again for the info.

    Plugin Contributor WP Rocket

    (@wp_rocket)

    We will keep in mind your feature requests for future releases of the plugin, thank you.

    Will this work with caching plugins that cache the entire HTML? Or will the HTML look different for Mobile vs Desktop?

    Plugin Contributor WP Rocket

    (@wp_rocket)

    You will need to enable the option to create a different cache file for mobile if the plugin you use has this (WP Rocket for example). Else it might not work indeed.

    Anonymous User 13882600

    (@anonymized-13882600)

    Sorry for hijacking the post but since WP Rocket is mentioned, I was wondering do I need this plugin if I have WP Rocket?

    Plugin Contributor WP Rocket

    (@wp_rocket)

    Hi,

    If you are using WP Rocket, you can use the Lazy Load option from WP Rocket. This plugin will be useless.

    Added the code

    add_filter( 'do_rocket_lazyload', function() {
        if ( ! wp_is_mobile() ) {
    	return false;
        }
    
        return true;
    } );

    but it has no effect. Images on mobile are still loaded without lazy load. Do I need to turn on lazy load in WP rocket for it to work on mobile and NOT on desktop in combination with the above code?

    I think it works now.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Lazy Load on Mobiles Only?’ is closed to new replies.