Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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

    #1305839

    Hey 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,
    Yigit

    #1305847

    Hi 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, 6 months ago by havi.
    #1305852

    Hi,

    Glad to hear that! You are welcome!

    Let us know if you have any other questions and enjoy the rest of your day :)

    Regards,
    Yigit

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Help with Fonts’ is closed to new replies.