• Resolved bstrokim

    (@bstrokim)


    I’m calling the buttons from theme files so as to display only on select templates. On Settings > Add To Any page, the “Placement” boxes are all unchecked. However, the plugin css and js still show up on the front end and therefore load. How to disable the css and js on pages without share buttons?

Viewing 2 replies - 1 through 2 (of 2 total)
  • no worries. I already accept the fact.???? You deserve to be happy???????

    Plugin Author micropat

    (@micropat)

    AddToAny supports dynamic loading, e.g. image sharing, content loaded via Ajax and similar publisher/developer use cases, so the required assets are available by default.

    You can conditionally disable the core AddToAny script and dequeue the plugin’s CSS & JS by adding the following PHP code using a “functionality” plugin such as the Code Snippets plugin:

    // Remove the AddToAny core script on some pages.
    add_action( 'wp_enqueue_scripts', function() {
        // Conditional goes here. For example:
        // Allow only on single posts (of any post type).
        if ( is_singular() ) return;
    
        // Remove the AddToAny core script.
        // Note: This disables AddToAny's ability to load dynamically.
        add_filter( 'addtoany_script_disabled', '__return_true' );
    }, 9);
    
    // Remove the AddToAny plugin's CSS/JS on some pages.
    add_action( 'wp_enqueue_scripts', function() {
        // Conditional goes here. For example:
        // Allow only on single posts (of any post type).
        if ( is_singular() ) return;
    
        // Remove the AddToAny plugin's JS & CSS.
        wp_dequeue_script( 'addtoany' );
        wp_dequeue_style( 'addtoany' );
    }, 21);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Placement boxes all unchecked but plugin css and js still show up on frontend’ is closed to new replies.