Home › Forums › WoodMart support forum › ow can I preload font-awesome ?
ow can I preload font-awesome ?
- This topic has 13 replies, 3 voices, and was last updated 5 years, 5 months ago by psivel.
-
AuthorPosts
-
June 6, 2019 at 11:48 am #127376
psivelParticipantHi,
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
June 6, 2019 at 5:29 pm #127421
Elise NoromitMemberHello,
You can upload the fonts by means of the custom font https://xtemos.com/docs/woodmart/contacts-2/
Best Regards
June 6, 2019 at 6:01 pm #127425
psivelParticipantThank 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…
June 7, 2019 at 6:40 am #127498
Artem TemosKeymasterTry 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 );
June 7, 2019 at 1:12 pm #127571
psivelParticipantHi,
Tried it but all my font-awesome icons are gone…
Ps
June 7, 2019 at 1:14 pm #127572
Artem TemosKeymasterPlease, send us your FTP and admin access.
June 7, 2019 at 1:21 pm #127578
psivelParticipantHere you go.
Thanks.
June 7, 2019 at 1:38 pm #127581
Artem TemosKeymasterTry 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 );
June 7, 2019 at 2:04 pm #127588
psivelParticipantOK thank you !
June 7, 2019 at 7:05 pm #127590
Artem TemosKeymasterYou are welcome.
June 7, 2019 at 9:53 pm #127628
psivelParticipantI’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.June 8, 2019 at 6:06 am #127637
Artem TemosKeymasterPlease, disable all external plugins so we can check.
June 10, 2019 at 8:30 am #127823
psivelParticipantOK 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
June 10, 2019 at 8:37 am #127826
psivelParticipantForget my last stupid question ;-(
-
AuthorPosts
- You must be logged in to create new topics. Login / Register