当前位置: 首页 > 工具软件 > LCP > 使用案例 >

获取网页的LCP

喻元龙
2023-12-01

LCP:最大内容绘制

var observer = new PerformanceObserver((entryList) => {
  var perfEntries = entryList.getEntries();
  var lastEntry = perfEntries[perfEntries.length - 1];
  var lcp = lastEntry.renderTime || lastEntry.loadTime;
  console.log('LCP:', lcp)
});
observer.observe({entryTypes: ['largest-contentful-paint']});
 类似资料: