1 of 103

Top Core Web Vitals recommendations for 2023

Barry Pollard

Web Performance Developer Advocate

Google Chrome

@tunetheweb

@tunetheweb@webperf.social

QR Code for slides on the last slide!

2 of 103

There is a LOT of webperf

advice out there

3 of 103

Credit: Tammy Everts - https://youtu.be/cnr3CJwpaps?t=804

What to measure?

4 of 103

https://web.dev/vitals/

Core Web Vitals

5 of 103

We now know what to measure

6 of 103

How to improve web performance?

7 of 103

How to improve web performance?

  • Lighthouse has 53 Performance audits

8 of 103

How to improve web performance?

  • Lighthouse has 53 Performance audits
  • Yellow Lab Tools has 38 checks

9 of 103

How to improve web performance?

  • Lighthouse has 53 Performance audits
  • Yellow Lab Tools has 38 checks
  • WebPageTest has 16 PAGES of stats

10 of 103

How to improve web performance?

  • Lighthouse has 53 Performance audits
  • Yellow Lab Tools has 38 checks
  • WebPageTest has 16 PAGES of stats
  • Chrome Dev Tools Performance Panel has 543,543,654,635,465 pieces of info (approximately)

11 of 103

It’s kinda overwhelming!!

12 of 103

What’s the most important things for me to look at for my site to really move the needle on my Core Web Vitals?

13 of 103

Focus on:

  • Recommendations we believe will have the largest real-world impact
  • Recommendations that are relevant and applicable to most sites
  • Recommendations that are realistic for most developers to implement

14 of 103

Top recommendations for each:

15 of 103

LCP recommendations

  • Ensure the LCP resource is discoverable from the HTML source

16 of 103

17 of 103

“HTML is parsed line-by-line”

Harry Roberts

Get your head straight

https://www.youtube.com/watch?v=MHyAOZ45vnU

18 of 103

19 of 103

HTML parser

AKA

“the big dog”

Photo by Vlad Rudkov on Unsplash

20 of 103

21 of 103

22 of 103

23 of 103

24 of 103

25 of 103

26 of 103

27 of 103

28 of 103

@tunetheweb

29 of 103

30 of 103

31 of 103

HTML is parsed line-by-line

(and it can often be paused)

32 of 103

The preload scanner

AKA

“the excitable little puppy”

Photo by Joe Caione on Unsplash

33 of 103

34 of 103

https://www.webpagetest.org

35 of 103

https://web.dev/preload-scanner/

36 of 103

How would I fight

the preload scanner?

37 of 103

38 of 103

39 of 103

The preload scanner

AKA

“the excitable little puppy”

Photo by Joe Caione on Unsplash

40 of 103

What if I need to execute JavaScript

to know what to display?

41 of 103

42 of 103

Don’t fight the preload scanner

43 of 103

Don’t fight the preload scanner

Make your resources discoverable

44 of 103

LCP recommendations

  • Ensure the LCP resource is discoverable from the HTML source
  • Ensure the LCP resource is prioritized

45 of 103

Browsers don’t prioritise images

46 of 103

Browsers don’t prioritise images

(initially)

47 of 103

48 of 103

49 of 103

50 of 103

  • Render-blocking resources
  • On-screen content
  • Off-screen content

Images are not render-blocking

Browsers fetch resources in several steps:

51 of 103

OK, but some of you might suggest…

52 of 103

A preload? Does that solve this?

53 of 103

https://web.dev/fetch-priority/

54 of 103

55 of 103

56 of 103

“...when we explicitly increase the priority of one resource we implicitly decrease the priority of others…”

Andy Davies

https://andydavies.me/blog/2019/02/12/preloading-fonts-and-the-puzzle-of-priorities/

57 of 103

Use fetchpriority to tell the

browser about important images

58 of 103

Use fetchpriority to tell the

browser about important images

(do not overuse)

59 of 103

LCP recommendations

  • Ensure the LCP resource is discoverable from the HTML source
  • Ensure the LCP resource is prioritized
  • Use a CDN to optimize document and resource TTFB

60 of 103

https://www.webpagetest.org/

61 of 103

https://almanac.httparchive.org/en/2022/cdn

CDNs are common - but less so for HTML

62 of 103

CLS recommendations

  • Set explicit sizes on any content loaded from the page

63 of 103

64 of 103

65 of 103

<img> with no width and height

66 of 103

<img> with width and height

67 of 103

It’s not just images!

68 of 103

69 of 103

CLS recommendations

  • Set explicit sizes on any content loaded from the page
  • Be eligible for bfcache

70 of 103

Better than loading fast…

…is loading instantly!

71 of 103

https://web.dev/bfcache/

72 of 103

https://web.dev/bfcache/

Chrome usage data shows that 1 in 10 navigations on desktop and 1 in 5 on mobile are either back or forward.

73 of 103

https://twitter.com/rnebhwani/status/1491388690601758720

74 of 103

75 of 103

https://web.dev/bfcache/#test-to-ensure-your-pages-are-cacheable

Test bfcache eligibility in DevTools

76 of 103

https://web.dev/bfcache/#test-to-ensure-your-pages-are-cacheable

Get the reasons why not eligible

77 of 103

https://www.smashingmagazine.com/2022/05/performance-game-changer-back-forward-cache/

78 of 103

CLS recommendations

  • Set explicit sizes on any content loaded from the page
  • Be eligible for bfcache
  • Avoid animations/transitions that use layout-inducing CSS properties

79 of 103

Layout-inducing CSS properties

https://web.dev/stick-to-compositor-only-properties-and-manage-layer-count/

Animations that change top / bottom / left / right cause CLS

This is even the case if they do not shift other content (for example with position: fixed)!

80 of 103

.box {

position: absolute;

top: 10px;

left: 10px;

animation: move 3s ease;

}

@keyframes move {

0% {

top: calc(90vh - 160px);

}

}

.box {

position: absolute;

top: 10px;

left: 10px;

animation: move 3s ease;

}

@keyframes move {

0% {

transform: translateY(calc(90vh - 160px));

}

}

🚫

Never animate using top / bottom / left / right

81 of 103

FID recommendations

82 of 103

Let’s talk about FID

https://httparchive.org/reports/chrome-ux-report#cruxFastFid

83 of 103

INP is a better responsive metric than FID

https://web.dev/inp/

84 of 103

INP measures all interactions and more of the interaction

https://web.dev/inp/#how-is-inp-different-from-first-input-delay-fid

85 of 103

INP measures all interactions and more of the interaction

https://web.dev/inp/#how-is-inp-different-from-first-input-delay-fid

This is what FID measures

86 of 103

INP measures all interactions and more of the interaction

https://web.dev/inp/#how-is-inp-different-from-first-input-delay-fid

This is what FID measures

(and only for the first interaction)

87 of 103

INP measures all interactions and more of the interaction

https://web.dev/inp/#how-is-inp-different-from-first-input-delay-fid

This is what INP measures

88 of 103

INP measures all interactions and more of the interaction

https://web.dev/inp/#how-is-inp-different-from-first-input-delay-fid

This is what INP measures

(and across all interactions)

89 of 103

INP can be thought of in three phases

Input delay

Processing time

Presentation delay

90 of 103

FID (and INP!) recommendations

  • Avoid or break up long tasks

91 of 103

https://web.dev/optimize-long-tasks/

92 of 103

https://web.dev/optimize-long-tasks/

JavaScript is greedy by nature

93 of 103

https://web.dev/optimize-long-tasks/

Manually defer code execution

94 of 103

JavaScript APIs

  • setTimeout
  • navigator.scheduling.isInputPending() - Chromium only
  • schedular.postTask() - Chromium only
  • scheduler.yield() - not available yet

95 of 103

FID (and INP!) recommendations

  • Avoid or break up long tasks
  • Avoid unnecessary JavaScript

96 of 103

Growth of JavaScript in last decade

https://httparchive.org/reports/state-of-javascript#bytesJs

97 of 103

Look at your Tag Managers

https://www.tunetheweb.com/blog/adding-controls-to-google-tag-manager/

98 of 103

  • Use defer (or modules)
  • Delay off screen social widgets
  • Lazy load iframes
  • Consider facades for 3p embeds

Late (or lazy) load third-party content

https://web.dev/embed-best-practices/

99 of 103

FID (and INP!) recommendations

  • Avoid or break up long tasks
  • Avoid unnecessary JavaScript
  • Avoid large rendering updates

100 of 103

Avoid large rendering updates

  • Keep DOM sizes small
  • Use CSS Containment
  • Avoid abusing requestAnimationFrame()

101 of 103

  • Ensure the LCP resource is discoverable from the HTML source
  • Ensure the LCP resource is prioritized
  • Use a CDN to optimize document and resource TTFB
  • Set explicit sizes on any content loaded from the page
  • Be eligible for bfcache
  • Avoid animations/transitions that use
  • Avoid or break up long tasks
  • Avoid unnecessary JavaScript
  • Avoid large rendering updates

Core Web Vitals: Top Developer Recommendations

102 of 103

https://web.dev/top-cwv-2023/

103 of 103

Thank you

Barry Pollard

@tunetheweb

@tunetheweb@webperf.social