Boosting Frontend Speed:
Quick Wins for Backend
Developers
Paul Conroy / @conroyp
Slide 2
Slide 2 text
Paul Conroy
From Dublin, Ireland
Started playing with the web 30+ years ago
(Notepad, Frontpage & Geocities!)
CTO at Square1
conroyp.com / @conroyp
๐ด
๐
๐ฎ๐ช
Slide 3
Slide 3 text
In the beginning
โ First website in 1991
โ Plain text, links - simple!
https://info.cern.ch/hypertext/WWW/TheProject.html
Slide 4
Slide 4 text
In the beginning
โ First website in 1991
โ Plain text, links - simple!
โ Img tag! Scrolling marquees!
โ Basic CSS
Slide 5
Slide 5 text
In the beginning
โ First website in 1991
โ Plain text, links - simple!
โ Img tag! Scrolling marquees!
โ Basic CSS
Slide 6
Slide 6 text
โ First website in 1991
โ Plain text, links - simple!
โ Img tag! Scrolling marquees!
โ Basic โ More advanced CSS
โ Interactivity (Java applets,
Flash, Javascript)
In the beginning
Slide 7
Slide 7 text
No content
Slide 8
Slide 8 text
No content
Slide 9
Slide 9 text
No content
Slide 10
Slide 10 text
Evolving ecosystem
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
No content
Slide 13
Slide 13 text
No content
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
No content
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
No content
Slide 19
Slide 19 text
No content
Slide 20
Slide 20 text
โThe site is slowโ
- Your boss
Slide 21
Slide 21 text
Improved metrics
โ Stand-alone metrics
โ Objectively quantify performance
โ Core Web Vitals - how does the site
interaction โfeelโ?
โ CLS, LCP, INP are key metrics
Slide 22
Slide 22 text
Improved metrics
โ Stand-alone metrics
โ Objectively quantify performance
โ Core Web Vitals - how does the site
interaction โfeelโ?
โ CLS, LCP, INP are key metrics
Slide 23
Slide 23 text
Improved metrics
โ CLS - how much do things jump
around on a page?
โ LCP - how long does to draw
the biggest thing on the page?
โ INP - how long between clicking
and seeing something happen?
Slide 24
Slide 24 text
โ Uses same data Google
uses in rankings
โ Based on real-world Chrome
user data
โ More than page speed!
Sitemaps, crawl errors,
inbound links
https://search.google.com/search-console/
Search Console
Lighthouse
โ?noads=1โ url toggle to get a โrawโ result
๐ก
Slide 32
Slide 32 text
How exactly are we meant
to improve a slow website?
Slide 33
Slide 33 text
Option 1
Slide 34
Slide 34 text
Option 1
Slide 35
Slide 35 text
Option 1
โ Send the team snowboarding
for 6 months
โ Browsers and hardware will
improve in that time
โ Problem solved
Slide 36
Slide 36 text
Option 1
โ Send the team snowboarding
for 6 months
โ Browsers and hardware will
improve in that time
โ Problem solved
โ Might need an Option 2โฆ
Slide 37
Slide 37 text
Images Ads Videos Fonts
Slide 38
Slide 38 text
Get rid of them all!
Slide 39
Slide 39 text
Improve page speed score?
Slide 40
Slide 40 text
โ
Improve page speed score
Slide 41
Slide 41 text
๐ ๐น ๐
โ
Improve page speed score
Slide 42
Slide 42 text
Images
Slide 43
Slide 43 text
โ Images are ~60% of average page load
โ More responsive sites โ more image sizes
being generated
โ Tricky to manage when handling user-
generated content!
IMAGES
JS
HTML
CSS, FONTS
Slide 44
Slide 44 text
No content
Slide 45
Slide 45 text
No content
Slide 46
Slide 46 text
Image sizing
โ Stops the image from appearing too large
Slide 47
Slide 47 text
Image sizing
โ Stops the image from appearing too large
โ Still requires a large image download
Slide 48
Slide 48 text
โ Stops the image from appearing too large
โ File size is appropriate to the image being
shown
Image sizing
โ Stops the image from appearing too large
โ Still requires a large image download
Slide 49
Slide 49 text
No content
Slide 50
Slide 50 text
No content
Slide 51
Slide 51 text
No content
Slide 52
Slide 52 text
No content
Slide 53
Slide 53 text
Choosing the right size
โ Detecting the browser size
based on User Agent /
headers
โ Generate different markup
based on browser size
Slide 54
Slide 54 text
Choosing the right size
โ Detecting the browser size
based on User Agent /
headers
โ Generate different markup
based on browser size
โ Impact on URL-based caching
โ How does it handle device
resizing after load?
Slide 55
Slide 55 text
Responsive images
โ Multiple sizes specified in markup
โ Browser picks best one to load
โ A single URL cache works fine!
โ Resizing of the browser?โจ
Right image size loaded
Slide 56
Slide 56 text
Smaller images?
โ Jpeg was the standard
โ Webp: 25 - 30% smaller than jpegโจ
Minimal quality drop
โ Avif: good for high end imagesโจ
Can be 10-15% smaller than Webp
โ JPEG XL is 10-15% smaller than AVIF
Slide 57
Slide 57 text
Smaller images?
โ Jpeg was the standard
โ Webp: 25 - 30% smaller than jpegโจ
Minimal quality drop
โ Avif: good for high end imagesโจ
Can be 10-15% smaller than Webp
โ JPEG XL is 10-15% smaller than AVIF
Slide 58
Slide 58 text
https://caniuse.com/?search=webp
Slide 59
Slide 59 text
https://caniuse.com/?search=avif
Slide 60
Slide 60 text
https://caniuse.com/?search=jpegxl
Slide 61
Slide 61 text
โ Content type hints
โ Browser will serve the first
image it can
โ Fallback to safer defaults
Slide 62
Slide 62 text
โ Important to โreserveโ space!
โ Tell the browser how much space
weโll need
โ Different sizes on different devices?
Define heights in media queries for
each breakpoint
Slide 63
Slide 63 text
No content
Slide 64
Slide 64 text
No content
Slide 65
Slide 65 text
No content
Slide 66
Slide 66 text
No content
Slide 67
Slide 67 text
No content
Slide 68
Slide 68 text
No content
Slide 69
Slide 69 text
No content
Slide 70
Slide 70 text
No content
Slide 71
Slide 71 text
No content
Slide 72
Slide 72 text
Impact on page speed
Slide 73
Slide 73 text
Impact on page speed
Slide 74
Slide 74 text
Lazy loading
โ Only load assets when they are
needed
โ Potentially save a lot of bandwidth
โ Load images just before they scroll
into view
Slide 75
Slide 75 text
Lazy loading
โ Only load assets when they are
needed
โ Potentially save a lot of bandwidth
โ Load images just before they scroll
into view
Slide 76
Slide 76 text
THEN
โ Load polyfill library
โ When image top is near
viewport, swap data-src and
src
โ Scroll listener thrashed
rendering thread!
Polyfills
Slide 77
Slide 77 text
Polyfills
THEN
โ Load polyfill library
โ When image top is near
viewport, swap data-src and
src
โ Scroll listener thrashed
rendering thread!
Slide 78
Slide 78 text
NOW
โ loading=โlazyโ ๐ฅ๐ฅ๐ฅ
โ Works on iframes too!
Polyfills
Slide 79
Slide 79 text
https://caniuse.com/?search=lazy
Slide 80
Slide 80 text
Lazyload everything?
Slide 81
Slide 81 text
โ Tempting to loading=โlazyโ all images
โ Actively harmful if applied to images
above the fold
โ Browser is trying to optimise loading - help
it out!
โ Use fetchpriority=โhighโ as a signal
Lazyload everything?
Slide 82
Slide 82 text
โ Specify relative priority with
fetchpriority
โ loading=โeagerโ is more defensive
(templates defaulting to lazy)
Slide 83
Slide 83 text
No content
Slide 84
Slide 84 text
No content
Slide 85
Slide 85 text
No content
Slide 86
Slide 86 text
Lazy loading background images
โ Background images usually
large, full width, lots of detail
โ CSS background-image
โ Limited polyfill support for
background images
Slide 87
Slide 87 text
Lazy loading background images
โ Background images usually
large, full width, lots of detail
โ CSS background-image
โ Limited polyfill support for
background images
โ IntersectionObserver
replaces window.scroll
Slide 88
Slide 88 text
IntersectionObserver
Slide 89
Slide 89 text
IntersectionObserver
Slide 90
Slide 90 text
IntersectionObserver
Slide 91
Slide 91 text
IntersectionObserver
Slide 92
Slide 92 text
IntersectionObserver
Slide 93
Slide 93 text
No content
Slide 94
Slide 94 text
No content
Slide 95
Slide 95 text
Images Ads Videos Fonts
Slide 96
Slide 96 text
No content
Slide 97
Slide 97 text
Display ads
โ We have no way of knowing if an ad
will show or not at render time
โ Page content โjumpingโ - very bad CLS
โ Very annoying for users!
โ Accidental clicks, maybe good for site
owners?
Slide 98
Slide 98 text
Display ads
โ We have no way of knowing if an ad
will show or not at render time
โ Page content โjumpingโ - very bad CLS
โ Very annoying for users!
โ Accidental clicks, maybe good for site
owners?
Slide 99
Slide 99 text
Two-click penalty
โ Google adds overlay on ads
โ Asks user to click again
โ Google donโt tell you this is happening!
โ It doesnโt show to every user
โ How do we know when itโs happening?
Slide 100
Slide 100 text
Two-click penalty
๐ ๐ ๐ธ
โ Google adds overlay on ads
โ Asks user to click again
โ Google donโt tell you this is happening!
โ It doesnโt show to every user
โ How do we know when itโs happening?
Slide 101
Slide 101 text
Avoiding the Two-click Penalty
โ Label ads clearly
โ Consistent spacing from content
โ Avoid areas near menus, buttons
โ Prevention is better than cure!
Slide 102
Slide 102 text
Reducing CLS
โ Min-height on the ad container,
matching expected ad unit size
โ Same technique as with images
Slide 103
Slide 103 text
โ Min-height on the ad container,
matching expected ad unit size
โ Same technique as with images
โ Ad loads in, taking the reserved
space, no CLS or โJumpingโ
Reducing CLS
Slide 104
Slide 104 text
โ Min-height on the ad container,
matching expected ad unit size
โ Same technique as with images
โ Ad loads in, taking the reserved
space, no CLS or โJumpingโ
Reducing CLS
Slide 105
Slide 105 text
Variable ad sizes?
โ Responsive ad sizes (single request)
โ Google might give us more than we
ask for!
โ How do we reserve the right space
for each ad possibility?
Slide 106
Slide 106 text
Variable ad sizes?
โ Responsive ad sizes (single request)
โ Google might give us more than we
ask for!
โ How do we reserve the right space
for each ad possibility?
Slide 107
Slide 107 text
Callbacks
โ slotRenderEnded
callback
โ When an ad loads, check
what div it was in
โ If ad is smaller than our
min height, remove the
min height
Slide 108
Slide 108 text
Callbacks
โ Set min height to that of
most popular ad unit
โ โBakes inโ some CLS, but
should be net positive
Slide 109
Slide 109 text
Results
โ Users experiencing bad CLS fell by 64% overnight
โ Regular review of most popular slots is critical
Slide 110
Slide 110 text
Images Ads Videos Fonts
Slide 111
Slide 111 text
User Engagement & SEO benefits!
โ Popular way to share content
โ Strong user engagement
โ Helps with SEO
โ Very expensive payloads!
Slide 112
Slide 112 text
Performance impact?
Slide 113
Slide 113 text
Performance impact?
Slide 114
Slide 114 text
Web components
Lite Youtube Embed by Paul Irish
This component:
โ Loads a placeholder image
โ On hover warms the
connection to youtube
โ On click, swaps the image for
the player code
Slide 115
Slide 115 text
Web components
Lite Youtube Embed by Paul Irish
This component:
โ Loads a placeholder image
โ On hover warms the
connection to youtube
โ On click, swaps the image for
the player code
Slide 116
Slide 116 text
Performance impact?
Slide 117
Slide 117 text
Performance impact?
Slide 118
Slide 118 text
Performance impact?
๐ข
๐ฐ
โกโกโก
Slide 119
Slide 119 text
SEO impact
โ Google is good at recognising
embedded videos!
โ Doesnโt recognise components
so well
โ Use structured data alongside
custom components
โ VideoObject schema
https://schema.org/VideoObject
Slide 120
Slide 120 text
Images Ads Videos Fonts
Slide 121
Slide 121 text
Web fonts
โ Brand โpersonalityโ, can
brighten up dull sites
โ Customisation has a cost!
โ Network requests
โ Render-blocking
โ Layout shifts
โ Feel like design, behaves like
infrastructure
Slide 122
Slide 122 text
CLS from font loading
Slide 123
Slide 123 text
CLS from font loading
Slide 124
Slide 124 text
CLS from font loading
Slide 125
Slide 125 text
CLS from font loading
Slide 126
Slide 126 text
CLS from font loading
Slide 127
Slide 127 text
No content
Slide 128
Slide 128 text
No content
Slide 129
Slide 129 text
No content
Slide 130
Slide 130 text
No content
Slide 131
Slide 131 text
No content
Slide 132
Slide 132 text
No content
Slide 133
Slide 133 text
No content
Slide 134
Slide 134 text
โ Variable fonts
โ Stores master outlines
โ Specifying the range, not each
value
Slide 135
Slide 135 text
No content
Slide 136
Slide 136 text
No content
Slide 137
Slide 137 text
I am loading: Best loading strategy:
1 font weight Single-weight font
2-3 font weights Depends - usually variable
4+ font weights Variable weight
When should I use a variable font?
Slide 138
Slide 138 text
What is a font?
Slide 139
Slide 139 text
Font subsetting
โ Remove all glyphs weโre not using
โ Significant reduction in file sizes
โ Support in modern tooling (vite, next.js, Google Fonts)
Slide 140
Slide 140 text
Font subsetting
pyftsubset Inter.var.ttf \
--unicodes=U+0020-007F \
--flavor=woff2 \
--layout-features='*'
Slide 141
Slide 141 text
Font subsetting
pyftsubset Inter.var.ttf \
--text-file=site-content.txt \
--flavor=woff2 \
--layout-features='*'
Slide 142
Slide 142 text
No content
Slide 143
Slide 143 text
No content
Slide 144
Slide 144 text
470 kB โ 83 kB
Slide 145
Slide 145 text
470 kB โ 83 kB
Slide 146
Slide 146 text
470 kB โ 83 kB
Slide 147
Slide 147 text
470 kB โ 83 kB
350 kB โ 72 kB
Slide 148
Slide 148 text
โ Faster fonts, unblock rendering thread sooner
โ LCP is probably an image, but is in a queue
โ Is this data telling me what I think it is?
Slide 149
Slide 149 text
No content
Slide 150
Slide 150 text
No content
Slide 151
Slide 151 text
No content
Slide 152
Slide 152 text
No content
Slide 153
Slide 153 text
No content
Slide 154
Slide 154 text
No content
Slide 155
Slide 155 text
No content
Slide 156
Slide 156 text
Incidents By Driver
Slide 157
Slide 157 text
No content
Slide 158
Slide 158 text
No content
Slide 159
Slide 159 text
No content
Slide 160
Slide 160 text
No content
Slide 161
Slide 161 text
โ When dealing with image issues, have we other blocking
resources?
โ Improving font loading unblocks threads - faster image loading!
โ Holistic view - top line metrics rarely influenced by solely one thing
Slide 162
Slide 162 text
Images Ads Videos Fonts
Slide 163
Slide 163 text
Whatโs next?
Slide 164
Slide 164 text
No content
Slide 165
Slide 165 text
RICK VISCOMI
โ Web Perf DevRel at Chrome
โ Optimisations for CWV
โ CrUX report data
https://bsky.app/profile/rviscomi.dev
WEB.DEV
โ Core Web Vitals
โ Modern browser technique guidance
โ Case studies, real world metrics
https://web.dev/
Slide 166
Slide 166 text
Images
Control what loads and when
โ Smaller file sizes: AVIF โ Webp โ Jpeg
โ Lazy loading
โ fetchpriority for hero images
Ads
Donโt let layouts move
โ Reserve space
โ Avoid the 2-click penalty!
โ Labelling and positioning are key
Videos
Load complexity only on interaction
โ Use facades inj place of heavy embeds
โ SEO impact! Structured data objects
Fonts
Reduce Weight. Prevent Shift
โ Variable fonts
โ Subset intentionally
โ Use size-adjust for fallbacks