Performance Metrics - WebPerf#0
Tags: webdev, webperf, performance, javascript
Published: 2022-08-18 08:16:09

You must have visited a lot of websites in your lifetime. And the user experience on the site is

![sometimes maybe good sometimes maybe shit meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xjbe1rswdax9oy0wqcl5.png)
 

Good site performance is sometimes vital for a good user experience (UX). But what is performance, how can it be measured, and how can it be improved? 

## Web Vitals

Web Vitals are the parameters on which a Site’s Performance is measured. Just like in a human body we have vitals like Blood Pressure, Pulse Rate, etc which are essential to know about the performance of a person, we have parameters like **Largest Contentful Paint, First Contentful Paint, Cumulative Layout Shift, First Input Delay,** etc to measure a website’s performance. 

## Core Web Vitals

Core Web Vitals are the subset of Web Vitals that apply to all web pages. The three Core Web Vitals are: 

- Largest Contentful Paint (LCP)
- First Input Delay (FID)
- Cumulative Layout Shift (CLS)

These core web vitals are based on the three main aspects of user experience: **Loading, Interactivity**, and **Visual Stability**

We will be learning these in very detail so here is a brief on them

### Largest Contentful Paint (LCP)

It is the time taken by the site to load the largest image or text block visible within the viewport of a site. 

![Largest Contentful Paint](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssybvk854zox06o07wgs.png)

### First Input Delay (TID)

It is the time from when a user first interacts with a page (i.e. click a link, tap on a button) to the time when the site is able to begin processing event handlers in response to that interaction.

![First Input Delay](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9m5rsee5etc8pxu5eyk4.png) 

### Cumulative Layout Shift (CLS)

You might have seen in some sites that the banner or the navbar is not rendered in the first go and is rendered afterward which causes the components below it to shift. CLS is a measure of that layout shift. 

![Cumulative Layout Shift](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/67fla27w3uxe2b4gguvq.png) 

## How is the core web vitals measured?

They can be measured by a variety of tools. Some of the most popular ones are:

- It can be measured by a tool present in the chrome browser itself known as Lighhouse. Or it can be installed as a [browser extension](https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk?hl=en)
- It can be also measured through [PageSpeed Insights](https://pagespeed.web.dev/)
- There is also a javascript library known as [web-vitals](https://github.com/GoogleChrome/web-vitals) which can be also used.

## Example of how Web Vitals looks like

![example of web vitals measurement](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qho6sotop2p9r9s5tz7f.png)
 

This is the measurement of my portfolio site. [swapandeep.com](http://www.swapnadeep.com) 

## Connect with me

> For more awesome JS or WebDev related blogs [check out my profile](https://dev.to/swapnadeepmohapatra)

[LinkedIn](https://www.linkedin.com/in/swapnadeep-mohapatra-11b371159/) [My Portfolio](https://www.swapnadeep.com/) [Twitter](https://www.twitter.com/swapnadeeptukk/) [Instagram](https://www.instagram.com/swapnadeep_mohapatra/)


Image credits: [web.dev](https://web.dev/)