Creating a custom Core Web Vitals performance monitoring system
As part of the Web API specification, one of the functionalities that’s included in web browsers as part of their runtime is PerformanceObserver. This observer can measure performance events that are recorded in the browser’s performance timeline and helps us to track the most important performance metrics of our web application.
How to do it…
In this recipe, we’ll build a small custom performance analytics observer to track the Core Web Vitals metrics and improve the performance of our web application, something we’ll do once we’ve identified performance bottlenecks. Once we’ve gathered the necessary metric information, we can send that data to our API analytics service.
Step 1 – Setting up Performance Observer
Since the PerformanceObserver Web API doesn’t follow the standard addEventListener/removeEventListener pattern for registering events...