ampproject / wg-performance

Monitoring and improving AMP's load and runtime performance for compliant documents. Facilitator: @erwinmombay
Creative Commons Attribution 4.0 International
7 stars 6 forks source link

Placeholder techniques for improving LCP #76

Closed CraigBusfield closed 3 years ago

CraigBusfield commented 3 years ago

We've been investigating on how to improve our LCP scores on our SSR'd product pages e.g. https://www.gaborshoes.co.uk/accessories-c32/handbags-c33/dina-ladies-messenger-handbag-p37007?attributes[1]=28179

One thing that we have encountered is that our main LCP element is not showing as soon as it is available, and it seems to be because these elements are images used as placeholders inside amp-carousels.

If you consider this Web Page Test timeline: https://www.webpagetest.org/video/compare.php?tests=210414_BiDcV4_163cbbdda397ebb6a143b8679cf01e91-r%3A1-c%3A0&thumbSize=200&ival=100&end=visual

Screenshot 2021-04-14 at 14 43 44

You'll see that the placeholder image displays at ~1.4s (this is being classed as the LCP), then the amp-carousel itself loads in at 1.6s, so you can no longer see the placeholder, and then the same image that's part of the carousel shows at 1.9s. However, if you look at the waterfall, you'll see that we have preloaded the image (line 3) and it is available to the browser at ~0.6s, so I would expect the placeholder element to be able to utilise the image at this point rather than waiting until ~1.4s.

Screenshot 2021-04-14 at 14 47 00

So my question is, have we implemented the placeholder element correctly, and if so is this the expected behaviour? If yes to both, is there any other recommended configuration that we could use here to improve our LCP score?

CraigBusfield commented 3 years ago

Closing this one as we discovered it was caused by a bug in the AMP PHP Toolbox, which handily was fixed in the latest release a couple of days ago https://github.com/ampproject/amp-toolbox-php/pull/122 😄

We've integrated the latest version and we're now seeing much better LCP scores (~0.7s) on that page as originally expected: https://www.webpagetest.org/video/compare.php?tests=210415_BiDc0N_569759fff8a41b7b3845493b668d633d-r%3A1-c%3A0&thumbSize=200&ival=100&end=visual

kristoferbaxter commented 3 years ago

Awesome, glad this was easily fixed!