Support » Plugin: AddToAny Share Buttons » Exclude preload on front page?

  • Resolved lily20171

    (@lily20171)


    Hi,

    I do not want to preload AddToAny on my homepage because I do not use/display it on my homepage but using it elsewhere (e.g. blog page).

    I disabled AddToAny option in every WP page that appears on my homepage, however AddToAny is still preloading on my homepage.

    The resource https://static.addtoany.com/menu/svg/icons.21.svg.js was preloaded using link preload but not used within a few seconds from the window’s load event. Please make sure it wasn’t preloaded for nothing.

    How can I exclude preloading just for the homepage? Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author micropat

    (@micropat)

    For best compatibility (particularly with Ajax themes and components) it’s not recommended, but you can disable AddToAny’s core page.js on your homepage by adding the following PHP code to your theme’s functions.php or similar:

    // Disable AddToAny core script on homepage
    function addtoany_disable_script_on_homepage($script_disabled) {
        if ( is_home() ) {
            return true;
        } else {
    	    return $script_disabled;
        }
    }
    add_filter( 'addtoany_script_disabled', 'addtoany_disable_script_on_homepage' );

    Regarding Chrome’s console message, it’s notoriously misleading because it doesn’t take overall optimizations into account. Google’s own performance projects get the same dumb message in Chrome as well, so it’s better to check out actual performance in the Network tab of DevTools when evaluating a resource in Chrome.

    In the case of page.js loading icons.*.svg.js via HTTP/2 server push, it’s always well-cached and loaded asynchronously so it never gets in the way of content loading.

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude preload on front page?’ is closed to new replies.