Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Challenging Assumptions About LCP Best Practice...

Estela Franco
November 03, 2023

Challenging Assumptions About LCP Best Practices (with data!)

When optimizing LCP, we can implement many techniques to improve its values. Each of these techniques focuses on a specific sub-part of LCP. But do you know which of these parts is more critical? Which optimizations should you prioritize to make a significant impact? In this talk, Estela will challenge the classic assumptions about optimizing LCP (using Chrome data!) and show how you can better prioritize your efforts to improve this metric.

Estela Franco

November 03, 2023
Tweet

More Decks by Estela Franco

Other Decks in Technology

Transcript

  1. Estela Franco - @guaca Why are you still talking about

    LCP? Everyone knows all about LCP and how to optimize its values.
  2. Estela Franco - @guaca LCP Metrics evolution over time •

    Chrome 77: ◦ Experimental metric exposed via API • Chrome 79: ◦ Metric is elevated to stable • Chrome 81: ◦ Metric definition improvements • Chrome 83: ◦ Metric definition improvements • Chrome 86: ◦ Metric definition improvements • Chrome 88: ◦ Metric definition improvements • Chrome 96 ◦ Metric bug fix • Chrome 98 ◦ Metric bug fix • Chrome 99 ◦ Implementation optimizations • Chrome 111 ◦ Implementation optimizations • Chrome 112 ◦ Metric definition improvements • Chrome 116 ◦ Metric definition improvements ◦ Implementation optimizations https://bit.ly/lcp-changelog
  3. Estela Franco - @guaca CLS Metrics evolution over time https://bit.ly/cls-changelog

    • Chrome 77 ◦ Experimental metric exposed via API • Chrome 79 ◦ Metric is elevated to stable • Chrome 85 ◦ Metric definition improvements • Chrome 86 ◦ Metric definition changes and bug: • Chrome 87 ◦ Metric definition improvements • Chrome 88 ◦ Metric definition improvements • Chrome 89 ◦ Metric definition improvements • Chrome 90 ◦ Metric definition improvements • Chrome 91 ◦ Metric definition improvements • Chrome 93 ◦ Metric definition improvements • Chrome 98 ◦ Metric definition improvements • Chrome 116 ◦ Implementation optimizations
  4. Estela Franco - @guaca FID Metrics evolution over time https://bit.ly/fid-changelog

    • Chrome 75 ◦ Metric definition improvement • Chrome 77 ◦ Metric exposed via API • Chrome 83 ◦ Metric definition improvement • Chrome 91 ◦ Chrome change affecting metric
  5. Estela Franco - @guaca INP Metrics evolution over time https://bit.ly/inp-changelog

    • Chrome 96 ◦ Experimental metric exposed via API • Chrome 109 ◦ Implementation optimizations • Chrome 111 ◦ Metric bug fix
  6. Estela Franco - @guaca Why are you still talking about

    LCP? Everyone knows all about LCP and how to optimize its values.
  7. Estela Franco - @guaca Let the data do the talking!

    CrUX data | Aug 2021 vs Aug 2022 vs Aug 2023
  8. Estela Franco - @guaca Let the data do the talking!

    CrUX data | Aug 2021 vs Aug 2022 vs Aug 2023
  9. Estela Franco - @guaca Let the data do the talking!

    CrUX data | Aug 2021 vs Aug 2022 vs Aug 2023
  10. Estela Franco - @guaca That’s WHY I’m still talking about

    LCP Everyone knows all about LCP and how to optimize its values but data says LCP is still bad.
  11. Estela Franco - @guaca Why is LCP still an issue?

    TTFB Resource Load Delay Resource Load Time Element Render Delay
  12. Estela Franco - @guaca Why is LCP still an issue?

    https://web.dev/articles/optimize-lcp HTML Document
  13. Estela Franco - @guaca Why is LCP still an issue?

    https://web.dev/articles/optimize-lcp Stylesheets
  14. Estela Franco - @guaca Why is LCP still an issue?

    https://web.dev/articles/optimize-lcp Image (LCP element)
  15. Estela Franco - @guaca Why is LCP still an issue?

    https://web.dev/articles/optimize-lcp JavaScript
  16. Estela Franco - @guaca Optimizing LCP sub-parts TTFB • Hosting

    • Optimize your backend • Use a CDN • Cache content
  17. Estela Franco - @guaca Optimizing LCP sub-parts TTFB • Hosting

    • Optimize your backend • Use a CDN • Cache content • Avoid page redirects
  18. Estela Franco - @guaca Optimizing LCP sub-parts TTFB • Hosting

    • Optimize your backend • Use a CDN • Cache content • Avoid page redirects • Use a service worker
  19. Estela Franco - @guaca Optimizing LCP sub-parts TTFB • Hosting

    • Optimize your backend • Use a CDN • Cache content • Avoid page redirects • Use a service worker • Use 103 Early Hints for render-critical resources
  20. Estela Franco - @guaca Optimizing LCP sub-parts Resource Load Delay

    • Discoverability ◦ Avoid JS-generated LCP elements
  21. Estela Franco - @guaca Optimizing LCP sub-parts Resource Load Delay

    • Discoverability ◦ Avoid JS-generated LCP elements. ◦ Preload images from stylesheets.
  22. Estela Franco - @guaca Optimizing LCP sub-parts Resource Load Delay

    • Discoverability ◦ Avoid JS-generated LCP elements. ◦ Preload images from stylesheets. • Priority
  23. Estela Franco - @guaca Optimizing LCP sub-parts Resource Load Delay

    • Discoverability ◦ Avoid JS-generated LCP elements. ◦ Preload images from stylesheets. • Priority ◦ Avoid lazy-loading LCP resources.
  24. Estela Franco - @guaca Avoid lazy-loading LCP resources Resource Load

    Delay https://calendar.perfplanet.com/2022/lazy-loading-lcp-images-why-does-this-anti-pattern-happen/
  25. Estela Franco - @guaca Avoid lazy-loading LCP resources Resource Load

    Delay https://almanac.httparchive.org/en/2022/performance#fig-15 June 2022 18%
  26. Estela Franco - @guaca Avoid lazy-loading LCP resources Resource Load

    Delay https://calendar.perfplanet.com/2022/lazy-loading-lcp-images-why-does-this-anti-pattern-happen/
  27. Estela Franco - @guaca Avoid lazy-loading LCP resources Resource Load

    Delay https://calendar.perfplanet.com/2022/lazy-loading-lcp-images-why-does-this-anti-pattern-happen/
  28. Estela Franco - @guaca Avoid lazy-loading LCP resources Resource Load

    Delay https://make.wordpress.org/performance/roadmap-2023/#category-images
  29. Estela Franco - @guaca Avoid lazy-loading LCP resources Resource Load

    Delay https://wordpress.org/plugins/lazy-load-control-for-elementor/
  30. Estela Franco - @guaca Avoid lazy-loading LCP resources Resource Load

    Delay https://performance.shopify.com/blogs/blog/shopify-google-improving-lcp-with-new-liquid-features
  31. Estela Franco - @guaca Avoid lazy-loading LCP resources Resource Load

    Delay https://github.com/HTTPArchive/custom-metrics/pull/94/files
  32. Estela Franco - @guaca Avoid lazy-loading LCP resources Resource Load

    Delay https://performance.shopify.com/blogs/blog/how-fast-is-your-shopify-theme
  33. Estela Franco - @guaca Optimizing LCP sub-parts Resource Load Delay

    • Discoverability ◦ Avoid JS-generated LCP elements. ◦ Preload images from stylesheets. • Priority ◦ Avoid lazy-loading LCP resources.
  34. Estela Franco - @guaca Optimizing LCP sub-parts Resource Load Delay

    • Discoverability ◦ Avoid JS-generated LCP elements. ◦ Preload images from stylesheets. • Priority ◦ Avoid lazy-loading LCP resources. ◦ Leverage fetchpriority attribute.
  35. Estela Franco - @guaca Leverage fetchpriority attribute Resource Load Delay

    https://web.dev/articles/optimize-lcp 2.6 s → 1.9 s
  36. Estela Franco - @guaca Optimizing LCP sub-parts Resource Load Time

    • Reduce the size of the resource. • Reduce the distance the resource has to travel.
  37. Estela Franco - @guaca Optimizing LCP sub-parts Resource Load Time

    • Reduce the size of the resource. • Reduce the distance the resource has to travel. • Reduce the network contention.
  38. Estela Franco - @guaca Optimizing LCP sub-parts Resource Load Time

    • Reduce the size of the resource. • Reduce the distance the resource has to travel. • Reduce the network contention. • Eliminate the network time entirely.
  39. Estela Franco - @guaca Optimizing LCP sub-parts Element Render Delay

    • Reduce or inline render-blocking stylesheets.
  40. Estela Franco - @guaca Optimizing LCP sub-parts Element Render Delay

    • Reduce or inline render-blocking stylesheets. • Defer or inline render-blocking JavaScript.
  41. Estela Franco - @guaca Optimizing LCP sub-parts Element Render Delay

    • Reduce or inline render-blocking stylesheets. • Defer or inline render-blocking JavaScript. • Break up long tasks.
  42. Estela Franco - @guaca Optimizing LCP sub-parts Element Render Delay

    • Reduce or inline render-blocking stylesheets. • Defer or inline render-blocking JavaScript. • Break up long tasks. • Use SSR (or SSG).
  43. Estela Franco - @guaca Optimal sub-part times ~40% <10% ~40%

    <10% https://web.dev/articles/optimize-lcp
  44. Estela Franco - @guaca Lighthouse PROS: • No development needed

    CONS: • “It works on my machine ¯\_(ツ)_/¯” alert
  45. Estela Franco - @guaca WebVitals Chrome extension PROS: • No

    development needed https://chrome.google.com/webstore/detail/web-vitals/ahfhijdlegdabablpippeagghigmibma
  46. Estela Franco - @guaca WebVitals Chrome extension PROS: • No

    development needed CONS: • “It works on my machine ¯\_(ツ)_/¯” alert https://chrome.google.com/webstore/detail/web-vitals/ahfhijdlegdabablpippeagghigmibma
  47. Estela Franco - @guaca JavaScript https://web.dev/articles/optimize-lcp • LCP API •

    Navigation Timing API • Resource Timing API CONS: • It requires development
  48. Estela Franco - @guaca JavaScript https://web.dev/articles/optimize-lcp • LCP API •

    Navigation Timing API • Resource Timing API PROS: • Synth and RUM data CONS: • It requires development
  49. Estela Franco - @guaca RUM Tools TTFB Resource Load Delay

    Resource Load Time Element Render Delay
  50. Estela Franco - @guaca RUM Tools TTFB Resource Load Delay

    Resource Load Time Element Render Delay
  51. Estela Franco - @guaca RUM Tools TTFB Resource Load Delay

    Resource Load Time Element Render Delay
  52. Estela Franco - @guaca RUM Tools TTFB Resource Load Delay

    Resource Load Time Element Render Delay
  53. Estela Franco - @guaca RUM Tools TTFB Resource Load Delay

    Resource Load Time Element Render Delay
  54. Estela Franco - @guaca HTTP Archive PROS: • Create your

    custom query for your needs CONS: • Query party 🎉
  55. Estela Franco - @guaca What’s next? • Collect data from

    Real Users ◦ JavaScript ◦ RUM tools
  56. Estela Franco - @guaca What’s next? • Collect data from

    Real Users ◦ JavaScript ◦ RUM tools • Define hypothesis & prioritize implementations
  57. Estela Franco - @guaca What’s next? • Collect data from

    Real Users ◦ JavaScript ◦ RUM tools • Define hypothesis & prioritize implementations • Validate in the lab ◦ PageSpeed Insights ◦ Lighthouse ◦ Chrome extension ◦ JavaScript
  58. Estela Franco - @guaca What’s next? • Collect data from

    Real Users ◦ JavaScript ◦ RUM tools • Define hypothesis & prioritize implementations • Validate in the lab ◦ PageSpeed Insights ◦ Lighthouse ◦ Chrome extension ◦ JavaScript • Validate in the field
  59. Estela Franco - @guaca Coming soon… TTFB Resource Load Delay

    Resource Load Time Element Render Delay
  60. Estela Franco - @guaca LCP sub-parts data in CrUX! The

    reaction I expect from the WebPerf Community 🤩
  61. Estela Franco - @guaca What’s next? • Collect data from

    Real Users ◦ JavaScript ◦ RUM tools ◦ CrUX • Define hypothesis & prioritize implementations • Validate in the lab ◦ PageSpeed Insights ◦ Lighthouse ◦ Chrome extension ◦ JavaScript • Validate in the field