https://web.dev/case-studies/rakuten
https://web.dev/case-studies/renault
https://web.dev/case-studies/swappie
A tunnel and lie-fi...
No signal
Underground
https://web.dev/case-studies/hotstar-inp
https://pixel-pionews.onrender.com
Largest Contentful Paint (LCP) is an important, stable Core Web Vital metric for measuring perceived load speed because it marks the point in the page load timeline when the page's main content has likely loaded—a fast LCP helps reassure the user that the page is useful.
https://web.dev/articles/lcp
1: Remember what problem you are trying to solve.
2: Look for potential problems that DevTools is showing you.
3: Verify & investigate each one.
No network activity + lots of activity on the main thread
Requests start again after the JavaScript is finished
Lots of main thread JavaScript after this request is completed
fetch heavy-processing.js
Evaluate Script (aka "run your JavaScript")
1. Fetch the JavaScript file
2. Execute the JavaScript
3. Finally! A chance to paint to the user.
https://developer.chrome.com/docs/devtools/performance/annotations
https://www.youtube.com/watch?v=cCOL7MC4Pl0
We load Roboto-Bold.ttf here
We also have some more heavy JavaScript
And here is when our text is rendered onto the page and we call it "done"
https://developer.chrome.com/blog/moving-lighthouse-to-insights
TTFB
How quickly did the server respond?
Render delay
The browser was busy so could not render the image.
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script
<script src="js/heavy-processing.js"></script>
<script src="js/heavy-processing.js" defer></script>
function planHoliday() {
bookHotel();
bookTrains();
}
function bookHotel() {
const nights = calculateNights();
book(nights)
}
function bookTrains() {
}
planHoliday()
bookHotel()
bookTrains()
calculateNights()
book(n...
time
your program running over time
sample
sample
sample
sample
planHoliday()
bookHotel()
bookTrains()
calculateNights()
book(nights)
time
planHoliday()
bookHotel()
bookTrains()
calculateNights()
book(nights)
time
planHoliday()
book(nights)
1: Do we need it at all?
2: Do we need it now?
// Also run some operations immediately (before DOMContentLoaded)
console.log("🔥 Starting immediate heavy processing...");
heavyDataProcessing();
heavySyncOperations();
// Add even more blocking operations before page render
console.log("🔥 Additional blocking operations...");
performExtraBlockingWork();
requestIdleCallback(() => {
// Also run some operations immediately (before DOMContentLoaded)
console.log("🔥 Starting immediate heavy processing...");
heavyDataProcessing();
heavySyncOperations();
// Add even more blocking operations before page render
console.log("🔥 Additional blocking operations...");
performExtraBlockingWork();
});
localhost:3000/home
main.css
Roboto-Bold.ttf
localhost:3000/home
main.css
Roboto-Bold.ttf
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/rel/preload
<link
rel="preload"
href="assets/Roboto-Bold.ttf"
as="font"
type="font/ttf"
crossorigin
/>
The DOMContentLoaded event fires when the HTML document has been completely parsed, and all deferred scripts have downloaded and executed. It doesn't wait for other things like images, subframes, and async scripts to finish loading.
https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event
The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets, scripts, iframes, and images, except those that are loaded lazily. This is in contrast to DOMContentLoaded, which is fired as soon as the page DOM has been loaded, without waiting for resources to finish loading.
https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
Expensive JS still runs but after the initial load.
Chrome usage data shows that 90% of a user's time on a page is spent after it loads, Thus, careful measurement of responsiveness throughout the page lifecycle is important. This is what the INP metric assesses.
Good responsiveness means that a page responds quickly to interactions. When a page responds to an interaction, the browser presents visual feedback in the next frame that it paints.
https://web.dev/articles/inp
https://pagespeed.web.dev/
1: What screen size are most of your users using?
2: What device (e.g. how powerful?) are your users using?
3: What network connection do they have?
1: Remember what problem you are trying to solve.
2: Look for potential problems that DevTools is showing you.
3: Verify & investigate each one.
4: Make sure your environment is as accurate as it can be.
5: Apply your own wisdom and knowledge; performance is full of nuance.
6: You can make trade-offs and you don't have to fix everything.