The performance of your web application can define the success of your website, the core web vitals are key metrics that help you to keep track and improve the user experience. This talk we will see how to optimize and measure a React application performance using some basic techniques, like code splitting with webpack, SEO optimization and bottleneck resolutions with examples.
1 of 53
Download to read offline
More Related Content
Optimizing a React application for Core Web Vitals
2. Juan Picado
Berlin - Germany
Senior Front-End Engineer at
mobile.de
Open Source at verdaccio.org
3. Agenda
What are Core Web Vitals?
Largest Contentful Paint (LCP)
Why are Core Web Vitals important?
First Input Delay (FID)
Cumulative Layout Shift (CLS)
Tooling
Web Performance Monitoring
Final Results
01
02
03
04
05
06
07
08
09
10
11
12
Field Data vs Lab Data
4. Use Case: Kijiji Autos
Launched in late 2018 in Canada
A classi鍖eds website
Microservices architecture
Node.js application
React Hooks
SEO Optimized
Accessibility First Citizen
9. Field Data
The lab data has as origin the
Chrome User Experience report
that collects anonymized metrics
from real users visiting your URL.
Limited to 28-day period
Real world data with all sort of
variables and unknowns.
10. Lab data
Controlled environment with
speci鍖c setup and conditions
For tracking bugs and
diagnosing issues
The Lighthouse score is the
weighted set of all web vitals
combined.
14. Fast delivering
Streaming server rendering with
renderToNodeStream
defer important scripts
CDN close to the users
Enforce Cache locally (cache-control)
15. Loading Fonts
Use font-display: swap; (CLS)
Serving fonts from our down domain
Use woff2
preload critical fonts
preconnect critical domains
18. Optimizing the critical rendering path
The plugin mini-css-extract-plugin
allows you to preload inline CSS
Cache assets content on render
Combination
react-universal-component to load
CSS 鍖les asynchronously
21. Optimizing css class names
Steps:
1. Assign a index for each class name
2. Convert the number to base64 string
to_base_64_number(class_name) + hash(鍖le_path)
1 { ... }
2 {...}
3 {...}.
65 {...}
.a { ... }
.b {...}
.c {...}
...
.aa { }
31. Intersection Observer API
Lazy-loading images or other
content as page is scrolled
Implement in鍖nite scrolling
Intersection Observer API - Web APIs | MDN (mozilla.org)
34. In鍖nite scroll implementation
Intersection Observer API to reduce
bundle size
Full modern browser support
Reserve space for content between
listings (eg: asynchronous ads)
Placeholders (skeletons) avoid CLS
Fetch data within the limited threshold
42. Speed curve Kijiji Autos
Run test over speci鍖c business key pages.
Mobile and Desktop (Ads enabled)
Web
Performance
Report
Speed Curve API
Every week fetch test results to
compare by week
Calculate the Lighthouse
Performance Score
Send to a slack channel that
weekly report
Custom Lab data
Cloud
Database
Save reports on the cloud to compare
with other Adevinta markets
44. Page Speed Insights
Field data and Lab
Data
Limited to 28 days
Metrics for the whole
website
Include all Web Vitals
Segmented peer page
45. Page Speed Insights
Field data and Lab
Data
Limited to 28 days
Metrics for the whole
website
Include all Web Vitals
Segmented peer page
46. CrUX Dashboard (Google Data Studio)
Only Field Data
Include dimensions
per device
Include all Web
Vitals
Relevant for high
tra鍖c websites
Open to the public
47. web-vitals library
Collect metrics directly
from users
navigator.SendBeacon()
submit metrics
Framework agnostic
Could be plugged in with
GA or custom endpoint
Integrated with Next.js
Gathering your own 鍖eld data
https://www.npmjs.com/package/web-vitals