Support » Plugin: WordPress Social Sharing Plugin - Sassy Social Share » Performance Optimization, Page Load speed, how to not load on home page?

  • Resolved xarelix

    (@xarelix)


    I am optimizing the speed and page load time on my website.

    I only use sassy social share on WooCommerce product pages.

    But I can see that some sassy social share code is always loaded on all pages.

    I have used code before to not load other code, such as this:

    add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11);
    function dequeue_woocommerce_cart_fragments() {
    if (is_front_page() || is_single() ) wp_dequeue_script('wc-cart-fragments');
    }

    I am wondering if something similar could be done for sassy social share, if so could you please share.

    Here is the code I wish to not load on my homepage, thank you:

    
    <script type="text/javascript">function heateorSssLoadEvent(e) {var t=window.onload;if (typeof window.onload!="function") {window.onload=e}else{window.onload=function() {t();e()}}};	var heateorSssSharingAjaxUrl = 'https://www.mysite.com/wp-admin/admin-ajax.php', heateorSssCloseIconPath = 'https://www.mysite.com/wp-content/plugins/sassy-social-share/public/../images/close.png', heateorSssPluginIconPath = 'https://www.mysite.com/wp-content/plugins/sassy-social-share/public/../images/logo.png', heateorSssHorizontalSharingCountEnable = 0, heateorSssVerticalSharingCountEnable = 0, heateorSssSharingOffset = -10; var heateorSssMobileStickySharingEnabled = 0;var heateorSssCopyLinkMessage = "Link copied.";var heateorSssUrlCountFetched = [], heateorSssSharesText = 'Shares', heateorSssShareText = 'Share';function heateorSssPopup(e) {window.open(e,"popUpWindow","height=400,width=600,left=400,top=100,resizable,scrollbars,toolbar=0,personalbar=0,menubar=no,location=no,directories=no,status")}</script>			<style type="text/css">
    					.heateor_sss_horizontal_sharing .heateorSssSharing{
    							color: #fff;
    						border-width: 0px;
    			border-style: solid;
    			border-color: transparent;
    		}
    				.heateor_sss_horizontal_sharing .heateorSssTCBackground{
    			color:#666;
    		}
    				.heateor_sss_horizontal_sharing .heateorSssSharing:hover{
    						border-color: transparent;
    		}
    		.heateor_sss_vertical_sharing .heateorSssSharing{
    							color: #fff;
    						border-width: 0px;
    			border-style: solid;
    			border-color: transparent;
    		}
    				.heateor_sss_vertical_sharing .heateorSssTCBackground{
    			color:#666;
    		}
    				.heateor_sss_vertical_sharing .heateorSssSharing:hover{
    						border-color: transparent;
    		}
    		@media screen and (max-width:783px) {.heateor_sss_vertical_sharing{display:none!important}}			</style>
    
    <link rel='stylesheet' id='heateor_sss_frontend_css-css'  href='https://www.mysite.com/wp-content/plugins/sassy-social-share/public/css/sassy-social-share-public.css?ver=3.2.5' type='text/css' media='all' />
    <link rel='stylesheet' id='heateor_sss_sharing_default_svg-css'  href='https://www.mysite.com/wp-content/plugins/sassy-social-share/public/../admin/css/sassy-social-share-svg.css?ver=3.2.5' type='text/css' media='all' />
    
    <script type='text/javascript' src='https://www.mysite.com/wp-content/plugins/sassy-social-share/public/js/sassy-social-share-public.js?ver=3.2.5'></script>
    
    • This topic was modified 1 year, 3 months ago by xarelix.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Heateor Support

    (@heateor)

    Inline CSS and Javascript will not add to the load time of your website.
    You can use following code to prevent CSS files sassy-social-share-public.css and sassy-social-share-svg.css from loading at homepage:

    /**
     * Prevent some CSS files from loading on homepage
     */
    function dequeue_heateor_sss_css() {
    	if ( is_front_page() ) {
    		wp_dequeue_style( 'heateor_sss_frontend_css' );
    		wp_dequeue_style( 'heateor_sss_sharing_default_svg' );
    	}
    }
    add_action( 'wp_enqueue_scripts', 'dequeue_heateor_sss_css', 11 );

    I appreciate the response, I really would prefer to not load any of the code until they are actually the product page, unless there is a valid reason to load the code on every page? or maybe its juts not a simple thing to do.

    I am still exploring options incase I can find a way for it to be more lightweight and clean, such as keeping css in css files, and not loading stuff when its not needed.

    • This reply was modified 1 year, 3 months ago by xarelix.
    Plugin Author Heateor Support

    (@heateor)

    The inline CSS and Javascript is being generated based on the variables calculated using PHP and that’s why it cannot be included in a CSS/JS file.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Performance Optimization, Page Load speed, how to not load on home page?’ is closed to new replies.