UNPKG

perfrunner-core

Version:

Automated UI performance test tool to measure performance changes for the web apps and sites

24 lines (23 loc) 785 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.measureLCP = void 0; function measureLCP() { const observer = new PerformanceObserver((entryList) => { const entries = entryList.getEntries(); const lastEntry = entries[entries.length - 1]; if (window._cpo) { window._cpo.add(lastEntry); } else { throw Error('storage not found'); } }); observer.observe({ type: 'largest-contentful-paint', buffered: true }); document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'hidden') { observer.takeRecords(); observer.disconnect(); } }); } exports.measureLCP = measureLCP;