Skip to content

Commit

Permalink
check for getEntriesByName in performance before calling
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Roebuck committed Jun 2, 2021
1 parent 7fd9ce5 commit 1a66913
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/getFCP.ts
Expand Up @@ -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) {
Expand Down

0 comments on commit 1a66913

Please sign in to comment.