• Resolved maximmmus

    (@maximmmus)


    Hi,

    I have placed this code before content on a page template, but the lazyload files are still loading on that page (checked with gtmetrix).

    Why is this code provided by plugin owner not disabling lazyload on that page?
    Thanks.

    <?php
    add_filter( 'a3_lazy_load_run_filter', 'skip_a3_lazy_load_for_this_page', 11 );
    function skip_a3_lazy_load_for_this_page( $apply_lazyload ) {
    $apply_lazyload = false;
    return $apply_lazyload;
    }
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter maximmmus

    (@maximmmus)

    By disabling Lazyload I mean to unregister it on that page template, which means the lazyload files are not loading on that page template. Is this not possible with the code above? Thank you.

    At that stage (before content on a page) is too late, the pugin has already been activated.

    You should put that code in functions.php and modify it by putting the condition by which you want the disable to take effect, inside the skip_a3_lazy_load_for_this_page function.

    So,

    1) put the code in functions.php

    2) add the condition, for instance if you want to disable on post ID 123:

    add_filter( 'a3_lazy_load_run_filter', 'skip_a3_lazy_load_for_this_page', 11 );
    function skip_a3_lazy_load_for_this_page( $apply_lazyload ) {
      if(is_single(123)){
        $apply_lazyload = false;
      }
      return $apply_lazyload;
    }
    Thread Starter maximmmus

    (@maximmmus)

    Hi,

    Thanks.
    That will still load css and js unfortunately. I would want those files not to be loaded on the page templates.

    Does anyone know how to unload the (css, js)? Thank you!

    • This reply was modified 5 years, 9 months ago by maximmmus.
    Plugin Contributor Nguyen Tuan

    (@nguyencongtuan)

    Hello

    This feature is added and I also reply on other topic from you at https://wordpress.org/support/topic/disable-on-specific-posts-homepage-archives-etc/#post-10562986

    Regards,
    Nguyen

    Thread Starter maximmmus

    (@maximmmus)

    Hi Nguyen,

    Thanks a lot! That is great news. Will you have a feature like this in the future?

    * Feature – Add exclude from Lazy Load by page_template

    That would be fantastic, because I use the same page_template on posts and pages and I also cannot exclude them by uri.

    🙂 Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Disable lazyload on page template’ is closed to new replies.