Tagged: lighthouse
-
AuthorPosts
-
June 14, 2021 at 6:49 pm #1305664
Hi guys!
Hope you are doing great.
I am facing some issues with LCP and would like to resolve them. This is from Lighthouse:
“Estimated Savings
Preload key requests
3.18 s
Consider using<link rel=preload>
to prioritize fetching resources that are currently requested later in page load. Learn more.FCPLCP
URL
Potential Savings
…poppins/poppins-regular.ttf(conversionsciences.com)
3,180 ms
…poppins/poppins-extralight.ttf(conversionsciences.com)
2,820 ms
…poppins/poppins-bold.ttf(conversionsciences.com)
2,400 ms”How do I preload these requests via Functions.php? And what’s the code I need to add? (Trying to avoid having to add it between <head>… </head> of the page/post template unless I can add it to the header.php that I already have on the Child theme.
TIA!!
Havi
June 15, 2021 at 4:24 pm #1305839Hey Havi,
Thanks! Hope you are doing great as well!
Could you please try adding following code to bottom of Functions.php file of your child theme
add_action( 'wp_head', function () { $upload_dir = wp_upload_dir(); ?> <link rel="preload" href="<?php echo $upload_dir['baseurl']; ?>/avia_fonts/type_fonts/poppins/poppins-regular.ttf" as="font" type="font/ttf" crossorigin> <link rel="preload" href="<?php echo $upload_dir['baseurl']; ?>/avia_fonts/type_fonts/poppins/poppins-extralight.ttf" as="font" type="font/ttf" crossorigin> <link rel="preload" href="<?php echo $upload_dir['baseurl']; ?>/avia_fonts/type_fonts/poppins/poppins-bold.ttf" as="font" type="font/ttf" crossorigin> <?php } );
Best regards,
YigitJune 15, 2021 at 4:46 pm #1305847Hi Yigit!!!
All is well around here!!! And I just added this to staging’s functions.php child’s theme and it worked like a charm!
I am going to add it to the live site.
Thank you!!
Havi
- This reply was modified 3 years, 5 months ago by havi.
June 15, 2021 at 4:50 pm #1305852 -
AuthorPosts
- The topic ‘Help with Fonts’ is closed to new replies.