Home
← All questions

How to measure the performance of a website? | Web Fundamentals

MediumPremiumWeb Fundamentals

Web Fundamentals interview practice: Tools and Core Web Vitals for measuring web performance.

Answer

Core Web Vitals (field metrics):

  • LCP (Largest Contentful Paint) — loading, target < 2.5s.
  • CLS (Cumulative Layout Shift) — visual stability, target < 0.1.
  • INP (Interaction to Next Paint) — responsiveness, target < 200ms (replaced FID).

Tools:

  • Lighthouse / PageSpeed Insights — lab audits + suggestions.
  • Chrome DevTools Performance & Network panels — flame charts, waterfalls.
  • PerformanceObserver / Navigation & Resource Timing APIs — real user monitoring (RUM).
  • web-vitals library to report metrics to analytics.
// Measure a code block
performance.mark("start");
doWork();
performance.mark("end");
performance.measure("work", "start", "end");
console.log(performance.getEntriesByName("work")[0].duration);

// Observe LCP
new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) console.log("LCP", entry.startTime);
}).observe({ type: "largest-contentful-paint", buffered: true });
Premium question

Unlock the full model answer with Mentoxis Premium.

Unlock with Premium