Site logo

Archived topic

Largest Contentful Paint Preload

1 reply · Started by Mike on June 2, 2021

Viewing posts 1–2 of 2

So here is what I am trying to accomplish - Decrease time of Largest Contentful Paint.

1. Using latest WP and GP Premium.
2. Using Siteground and SG Optimizer, etc.
3. Images compressed and in webp format.

Blah, blah, blah...all usual speedup tricks enabled

This is NOW what I am trying to do.

1. Have added a header.php file to my child theme, and inside at the bottom of this file I have added the line

<link rel="preload" as="image"https://www.mywebiste.com/wp-content/uploads/2021/05/my-home-page.webp>

This is the error i get back

Parse error: syntax error, unexpected '<', expecting end of file in /home/customer/www/mywebsite.com/public_html/wp-content/themes/generatepress_child/header.php on line 77

I also tried this line

<link rel='preload' https://www.mywebsite.com/wp-content/uploads/2021/05/my-home-page.webp' as='image'>

Same result. Seems as though this should work. Got the idea from the following resource...usually pretty good. https://onlinemediamasters.com/preload-key-requests-wordpress/

Any ideas?

Hi there,

if you want to add something the <head> of your site - you don't need to create a new header.php. So delete that.
Instead create a new Hook Element:

https://docs.generatepress.com/article/hooks-element-overview/

Add the link code you want to the hook content.
From the Hook list, select: wp_head

Then set the Display Rules to: Entire Site or the specific pages/posts/archives you want it displayed on.

This archived topic is closed to new replies.