Support » Plugin: WP Socializer » Optimization to host External Styles and Script

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author vaakash

    (@vaakash)

    Thanks, I’ll make a note and add a filter.
    For now please replace L31 with below.

    $res = apply_filters( 'wpsr_mod_ext_res', array(

    and L39 with below

    ));

    You can then use the filter wpsr_mod_ext_res as you like.

    Aniket Belwalkar

    (@aniketbelwalkar)

    Hi @vaakash,

    I have tried to add the filter to core file of the plugin as you suggested and tried to hook into this filter in order to localize few scripts. However after multiple tries it seems that the resource links are loaded much before the initial Hooks of WordPress runs which results in no chance to hook in custom functions.

    Here is the code I tried.

    function cust_wpsr_mod_ext_res( $res ) {
    
    	$res['font-awesome'] = get_stylesheet_directory_uri() . '/wp-socializer/css/font-awesome.min.css';
    
    	$res['socializer-css'] = get_stylesheet_directory_uri() . '/wp-socializer/css/socializer.min.css';
    
    	return $res;
    
    }
    add_filter( 'wpsr_mod_ext_res', 'cust_wpsr_mod_ext_res' );

    Is there any other possibility to add the localized resource which you would suggest.

    @vaakash any updates on this? Do let me know as its a critical issue for our site’s performance on all the pages wherever we have enabled this functionality.

    Plugin Author vaakash

    (@vaakash)

    Ok, looks like it didn’t work.
    Please try below methods where I’m de-registering the style and registering again.
    I tried locally and it worked for me.

    function remove_wpsr_styles() {
        wp_deregister_style('wpsr_main_css');
        wp_register_style('wpsr_main_css', '<wp socializer main css>');
        
        wp_deregister_style('wpsr_sb_fa_css');
        wp_register_style('wpsr_sb_fa_css', '<font awesome css>');
    }
    add_action('wp_enqueue_scripts', 'remove_wpsr_styles', 30);

    Thanks,
    Aakash

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