【发布时间】:2018-04-12 07:09:28
【问题描述】:
我正在实施 PerformanceObserver 来跟踪“first-paint”和“first-contentful-paint”。
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (typeof(Storage) !== 'undefined') {
if (entry.name === 'first-paint') {
localStorage.setItem(rumMetrics.RUM_METRICS_FIRST_PAINT, entry.startTime);
}
else if (entry.name === 'first-contentful-paint') {
localStorage.setItem(rumMetrics.RUM_METRICS_FIRST_CONTENTFUL_PAINT, entry.startTime);
}
}
else {
console.log('local storage is not supported here. RUM metrics won\'t be recorded.');
}
}
});
observer.observe({ entryTypes: ['paint'] });
这在 Chrome 中完美运行但在 Firefox 中引发错误。
TypeError: The expression cannot be converted to return the specified type. (line: observer.observe({ entryTypes: ['paint'] });)
【问题讨论】:
-
听起来像是要报告bugzil.la
标签: performance pagespeed observers mutation-observers