Home Forums WoodMart support forum ow can I preload font-awesome ?

ow can I preload font-awesome ?

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #127376

    psivel
    Participant

    Hi,

    I’m doing google pagespeed tests and the main problem seems to be “preloading key requests” which make me lose almost 3 seconds. In the advice section I just see 2 occurrences of the same font (fontawesome-webfont.woff2) loaded by woodmart and yith woocommerce wishlist.

    Google pagespeed’s advice is to use <link rel=preload> for this resource. How can I achieve this ?

    Thank you.

    Pierre

    #127421

    Hello,

    You can upload the fonts by means of the custom font https://xtemos.com/docs/woodmart/contacts-2/

    Best Regards

    #127425

    psivel
    Participant

    Thank you but if I load font awesome as a custom font will it remove the <link> call in the header from Woodmart and yith wishlist ? I need to get rid of these calls because they are content blocking and slow down my site…

    #127498

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    function add_rel_preload( $html, $handle, $href, $media ) {
    	if ( is_admin() ) {
    		return $html;
    	}
    
    	if ( 'font-awesome-css' === $handle || 'yith-wcwl-font-awesome' === $handle ) {
    		return '<link rel="preload" id="' . $handle . '-css" href="' . $href . '" type="text/css" media="' . $media . '" />';
    
    	}
    
    	return $html;
    }
    
    add_filter( 'style_loader_tag', 'add_rel_preload', 10, 4 );
    #127571

    psivel
    Participant

    Hi,

    Tried it but all my font-awesome icons are gone…

    Ps

    #127572

    Artem Temos
    Keymaster

    Please, send us your FTP and admin access.

    #127578

    psivel
    Participant

    Here you go.

    Thanks.

    #127581

    Artem Temos
    Keymaster

    Try to replace the code with the following one

    function add_rel_preload( $html, $handle, $href, $media ) {
    	if ( is_admin() ) {
    		return $html;
    	}
    
    	if ( 'font-awesome-css' === $handle || 'yith-wcwl-font-awesome' === $handle ) {
    		return '<link rel="preload" as="style" onload="this.rel = \'stylesheet\'" id="' . $handle . '-css" href="' . $href . '" type="text/css" media="' . $media . '" />';
    
    	}
    
    	return $html;
    }
    
    add_filter( 'style_loader_tag', 'add_rel_preload', 10, 4 );
    #127588

    psivel
    Participant

    OK thank you !

    #127590

    Artem Temos
    Keymaster

    You are welcome.

    #127628

    psivel
    Participant

    I’m sorry but in my earlier message I didn’t have time to do the google pagespeed test again. I did it tonight and the problem is still here. See attachment. What can I do ?

    Attachments:
    You must be logged in to view attached files.
    #127637

    Artem Temos
    Keymaster

    Please, disable all external plugins so we can check.

    #127823

    psivel
    Participant

    OK thank you the issue have been solved by wp fastest cache.

    Another question: Is there a way to display up sell/cross sell products in the cart page / order validation page ?

    Thanks.

    Pierre

    #127826

    psivel
    Participant

    Forget my last stupid question ;-(

Viewing 14 posts - 1 through 14 (of 14 total)