- This topic has 14 replies, 3 voices, and was last updated 6 months ago by
Fernando.
-
AuthorPosts
-
September 18, 2022 at 4:27 am #2346410
Thomas
Hi,
I have found that Google Search Console is flagging all my single post pages as having LCP Issues in core web vitals. I have checked on Google page speed and the LCPfor Desktop is good (1 second) but Mobile is poor (3-6 seconds).
I have Autoptimise (used recogmended settings for Generate Press) and WP Supercache running. I have managed to reduce the problem a bit (about 1 second) by converting images to Webp, lazy loading and adding a background colour to the Header image container. However at this point, I am a bit stuck for ideas! Is there anything you can suggest as it seems the large header image on Mobile is what it doesn’t like, but that is a main element of the overall theme.
The frustrating part is by using another Performance Tool such as GTMetrix the site looks great, it just seems Google has an issue with it!
Link to pagespeed and site in private info box.
Best, Tom
September 18, 2022 at 7:54 am #2346666David
StaffCustomer SupportHi there,
First off LCP can never be quicker than FCP. So we should focus on improving FCP first as any improvement there will flow down to LCP.
The major performance hogs are:
1. Google Fonts
Loading them locally can significantly improve that.https://docs.generatepress.com/article/adding-local-fonts/
2. 3rd party scripts particularly adverts.
You can defer those scripts using a plugin like:https://wordpress.org/plugins/async-javascript/
https://wordpress.org/plugins/flying-scripts/As well as the popular plugins like Perfmatters or WP rocket.
If you want to make those changes first we can then relook at the additional time between FCP and LCP improvements.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 18, 2022 at 9:21 am #2346700Thomas
Thanks David, that was really helpful.
I have;
Switched to loading Google fonts locally.
Installed Async Javascript, and defered the two advertising javascripts and google tag manager script.This has improved FCP a lot, now about 1.4 seconds, but the LCP is still high (4.2 seconds) on the homepage, and simular on posts.
I am getting a warning that I am lazily loading the largest image on Pagespeed. I am using Autooptimise and have made sure to lazy load the 4th image onwards and have added what I think is the image classes of the images in the single page featured image header/magazine layout, but I must be going wrong somewhere?
My lazy load excluded images classes are;
first-featured-image,wp-show-posts-image img,img.attachment-full,div.wp-show-posts-image ,wp-show-posts-imageDo correct me on these, and happy to look at any more suggestions to get the LCP down on mobile.
September 18, 2022 at 11:51 pm #2347048Fernando Customer Support
Hi Thomas,
Perhaps you can also try using a CDN? Using a CDN should improve delivery of your site’s resources.
A popular CDN would be Cloudflare. This link might also be helpful: https://www.wpbeginner.com/showcase/best-wordpress-cdn-services/
September 21, 2022 at 8:37 am #2349713Thomas
Thanks. At present I am not looking at a CDN, I would rather resolve this issue as it seems we are pretty close.
Do please review my reply above. I need to know what are the image clasess for the featured images, as currently all images are lazy loading, which is the only thing holding it back now.
September 21, 2022 at 9:26 pm #2350211Fernando Customer Support
Can you try excluding
wp-post-image
just to test?September 23, 2022 at 12:43 am #2351360Thomas
Hi,
I have added the above image class to the exclusion on Autoptimize. I have cleared all the caches now, and re-run the Google Lighthouse test which is still reporting..
Largest Contentful Paint image was lazily loaded
Above-the-fold images that are lazily loaded render later in the page lifecycle, which can delay the largest contentful paint.
img.attachment-full.size-full.wp-post-imageI have previously added the full class written above to the exclusion but that seems to make no difference.
September 23, 2022 at 12:58 am #2351370Fernando Customer Support
I see. Can you try adding this to test?:
function db_disable_wp_lazy_home_featured( $default, $tag_name, $context) { if ( is_home() && 'img' === $tag_name && 'wp_get_attachment_image' === $context ) { return false; } return $default; } add_filter( 'wp_lazy_loading_enabled', 'db_disable_wp_lazy_home_featured', 10, 3);
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
September 23, 2022 at 1:13 am #2351378Thomas
Thanks. I have added that function and cleared all caches again, but it is still showing as lazy loading for me?
I have found that has improved the post pages as the top featured image is now not loading lazy and the page scores have got better. It is just the homepage with the image in the top “magazine” tile header, that is still lazy loading.
September 23, 2022 at 1:21 am #2351381Fernando Customer Support
I see. Can you try this instead?:
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
September 23, 2022 at 1:25 am #2351383Thomas
Thanks.
I have added that snippet, but disabled the previous one. I have cleared the cache.
I do still have lazy loading turned on in Autoptimise, do let me know if i should turn that off?
September 23, 2022 at 1:45 am #2351403Fernando Customer Support
Actually, just realized that the
loading=lazy
attribute is a browser-level lazy loader. By default images above the fold (ATF) will not be lazy loaded by it.More info on the spec here: https://web.dev/browser-level-image-lazy-loading/
Can you try temporarily disabling Autoptimize to see if anything changes?
September 23, 2022 at 1:59 am #2351414Thomas
Thanks, I didn’t know that either.
Ok have disabled Lazy Loading in Autoptimze now and cleared caches.
September 23, 2022 at 8:29 am #2351797Thomas
Hi,
Just to let you know i think I have resolved it. I found this post with a slightly different filter in it. Adding this helped and seemed to sort out the lazy loading problem.
I have then made sure the locally added Fonts have the FontDisplay:Swap atribute as that was missing adding to the delay. All seems have improved things quite a lot. I am targeting the UK and that’s where the server is, so the server response locally was quite good and now is very good. It just seems that Google is using a US based server which is always a bit slower.
Thanks for your help, I’m going to say this is resolved!
September 25, 2022 at 5:01 pm #2353533Fernando Customer Support
Nice! Glad you found the solution!
-
AuthorPosts
- You must be logged in to reply to this topic.