From 1a66913dd4cfcfec6f79b89b218a0890c6005629 Mon Sep 17 00:00:00 2001 From: Jonathan Roebuck Date: Wed, 2 Jun 2021 16:39:39 +0100 Subject: [PATCH] check for getEntriesByName in performance before calling --- src/getFCP.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getFCP.ts b/src/getFCP.ts index 65f0bd1a..c681bbe8 100644 --- a/src/getFCP.ts +++ b/src/getFCP.ts @@ -46,7 +46,7 @@ export const getFCP = (onReport: ReportHandler, reportAllChanges?: boolean) => { // TODO(philipwalton): remove the use of `fcpEntry` once this bug is fixed. // https://bugs.webkit.org/show_bug.cgi?id=225305 - const fcpEntry = performance.getEntriesByName('first-contentful-paint')[0]; + const fcpEntry = 'getEntriesByName' in performance ? performance.getEntriesByName('first-contentful-paint')[0] : null; const po = fcpEntry ? null : observe('paint', entryHandler); if (fcpEntry || po) {