pwstrick / daily

一份搜集的前端面试题目清单、面试相关以及各类学习的资料(不局限于前端)
2.35k stars 243 forks source link

FP和FCP是指什么?如何计算? #979

Open pwstrick opened 4 years ago

pwstrick commented 4 years ago

FP和FCP是指什么?如何计算?

ke1vin4real commented 4 years ago

@pwstrick FMP在最新版Lighthouse已经废弃了,这个指标意义不大

pwstrick commented 4 years ago

@pwstrick FMP在最新版Lighthouse已经废弃了,这个指标意义不大

好的 我修改一下

pwstrick commented 4 years ago

FP(First Paint),首次绘制,第一个像素点绘制的时间。

const FP = performance.getEntriesByName('first-paint')[0].startTime

FCP(First Contentful Paint),首次内容绘制,第一个DOM元素渲染页面的时间。

const FCP = performance.getEntriesByName('first-contentful-paint')[0].startTime

参考 performance.getEntriesByName()PerformanceEntry.name