How to evaluate Largest Contentful Paint using Playwright



AI Summary

This video explains how to gather web performance metrics like Largest Contentful Paint (LCP) using Playwright scripts. It demonstrates spinning up a browser, navigating to a website, and using page.evaluate to run JavaScript in the page context. A PerformanceObserver is initialized to monitor web performance events, specifically LCP. The observer collects entries, and the script extracts the last entry as the LCP value, returning its start time to Node.js. The example logs the LCP time around 500 milliseconds. The video also advises parsing the LCP value from string to number for further operations. Additional resources for measuring page performance with Playwright or Puppeteer are briefly mentioned.