Support » Plugin: AddToAny Share Buttons » Remove AddToAny javascript code if not needed

  • Resolved mensmaximus


    Although you can disable AddToAny to be displayed on pages the Javascript code is still loaded on pages. To reduce code and to speed up page load it would be better to not load the Javascript code if it is not needed. I guess many users would appreciate this feature in an upcoming release of AddToAny.

    In addition to allow the usage of AddToAny in Europe to be compliant to the EU e-Privacy Directive it would be useful to introduce a new parameter to the additional options to prevent AddToAny from loading until a cookie has been set. The name of the cookie should be the value of the new parameter. This way administrators could use any of the existing WordPress cookie plugins. I would love to see something like

    a2a_config.cookieinit = ‘name_of_the_cookie_needed_to_load_a2a’

    Kind regards


Viewing 4 replies - 1 through 4 (of 4 total)
  • I forgot to mention I solved the first issue (javascript code loading although display on pages is disabled) by altering the following functions in add-to-any.php:


    I put this code below the is_admin if-statement in both functions:

    $options = get_option( 'addtoany_options' );
    if ( $options['display_in_pages'] != '1' && is_page () )
    Plugin Author micropat


    Thanks for your feedback, Michael! These are good requests that will be considered in future releases. Some color:

    The plugin currently loads the script [asynchronously] for most requests so that AddToAny can be reliably loaded from AJAX (widgets, infinite scrolls, etc.).

    To support your use-case most immediately I think it’d be interesting to make the script functions modifiable by filters, so you can disable the script programmatically (probably in your functions.php) without having to modify the plugin itself. How does that sound?

    It would be perfect to have a hook to enable/disable the script programmatically.

    Plugin Author micropat


    The addtoany_script_disabled hook was added in version 1.3.2.

    Example usage:
    add_filter( 'addtoany_script_disabled', '__return_true' );

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove AddToAny javascript code if not needed’ is closed to new replies.