Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
766 views
in Technique[技术] by (71.8m points)

pagespeed - Struggling to get CLS down under 0.1s on mobile. Can't reproduce it on tests

I try to optimize the whole Pagespeed of this page but I can't get the CLS under 0.1 on mobile. I really don't know why as I use critical css, page-caching and font-preloading and I cant reproduce the behaviour in tests.

https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fwww.birkengold.com%2Frezept%2Fselbstgemachte-zahnpasta

Tested with an simulated Galaxy S5 on 3G Fast. https://www.webpagetest.org/result/210112_DiK9_256ca61d8f9383a5b927ef5f55644338/

In no Scenario I get somewhere near the 0.1 in CLS.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Field Data and Origin Summary

Field data and Origin Summary are real world data.

There is the key difference between these metrics and the synthetic test that Page Speed Insights runs.

For example: CLS is measured until page unload in the real world, as mentioned in this explanation on CLS from Addy Osmani who works on Google Chrome.

For this reason your CLS can be high for pages if they perform poorly at certain screen sizes (as Lighthouse / PSI only tests one mobile screen size by default) or if there are things like lazy loading not performing well in the real world and causing layout shifts when things load too slowly.

It could also be certain browsers, connection speeds etc. etc.

How can you find the page / root cause that is ruining your Web Vitals?

Let's assume you have a page that does well in the Lighthouse synthetic test but it performs poorly in the real world at certain screen sizes. How can you identify it?

For that you need to gather Real User Metrics (RUM) data.

RUM data is data gathered in the real world as real users use your site and stored on your server for later analysis / problem identification.

There is an easy way to do this yourself, using the Web Vitals Library.

This allows you to gather CLS, FID, LCP, FCP and TTFB data, which is more than enough to identify pages that perform poorly.

You can pipe the data gathered to your own API, or to Google Analytics for analysis.

If you gather and then combine the web vitals information with User Agent strings (to get the browser and OS) and the browser size information (to get the effective screen size) you can narrow down if the issue is down to a certain browser, a certain screen size, a certain connection speed (as you can see slower connections from high FCP / LCP figures) etc. etc.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...