Support » Plugin: AddToAny Share Buttons » defer javascript

  • Resolved wasanajones

    (@wasanajones)



    Hi – thanks for great plugin

    I’ve got facebook like count enabled and the scripts coming from FB are delaying page loading.

    is there a way to

    1) load them from local
    2) disable on mobile

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author micropat

    (@micropat)

    You’re welcome. 🙂

    FYI: All count requests are loaded asynchronously, so they’re already non-blocking.

    1. There’s no local option for counts partly because it would introduce accuracy and performance issues.

    2. You can disable count requests on mobile by filtering AddToAny options like the following example:

    function disable_share_counts_on_mobile( $addtoany_options ) {
    	if ( wp_is_mobile() ) {
    		// Disable universal share counter
    		$addtoany_options['button_show_count'] = '-1';
    
    		// Disable Facebook share counter
    		if ( ! empty( $addtoany_options['special_facebook_options'] ) ) {
    			$addtoany_options['special_facebook_options']['show_count'] = '-1';
    		}
    	}
    
    	return $addtoany_options;
    }
    
    add_filter( 'option_addtoany_options', 'disable_share_counts_on_mobile' );

    Just add the above PHP code to your site using a “functionality” plugin such as the Code Snippets plugin.

    wasanajones

    (@wasanajones)

    Hi – thanks for thorough reply

    my thread title was inaccurate but I couldn’t edit it- oops

    I’m pretty sure not loading from FB would violate their TOS but they can be slow

    I appreciate the detail of the script solution

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.