From 79384034cf6f15381ec90a60d544f02eff0b601e Mon Sep 17 00:00:00 2001 From: Florian Scholz Date: Mon, 12 Dec 2022 18:37:41 +0100 Subject: [PATCH] Document limitations of performance.getEntries* methods (#22841) * Document limitations of performance.getEntries* methods * Move out of note --- .../web/api/performance/getentries/index.md | 20 ++++++++++++------- .../api/performance/getentriesbyname/index.md | 10 ++++++++++ .../api/performance/getentriesbytype/index.md | 10 ++++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/files/en-us/web/api/performance/getentries/index.md b/files/en-us/web/api/performance/getentries/index.md index c75a65d6323b1ca..f551e9fec2af1d1 100644 --- a/files/en-us/web/api/performance/getentries/index.md +++ b/files/en-us/web/api/performance/getentries/index.md @@ -19,6 +19,16 @@ If you are only interested in performance entries of certain types or that have > **Note:** This method does not notify you about new performance entries; you will only get entries that are present in the performance timeline at the time you call this method. > To receive notifications about entries as they become available, use a {{domxref("PerformanceObserver")}}. +The following entry types are not supported by this method at all and won't be returned even if entries for these types might exist: + +- `"element"` ({{domxref("PerformanceElementTiming")}}) +- `"event"` ({{domxref("PerformanceEventTiming")}}) +- `"largest-contentful-paint"` ({{domxref("LargestContentfulPaint")}}) +- `"layout-shift"` ({{domxref("LayoutShift")}}) +- `"longtask"` ({{domxref("PerformanceLongTaskTiming")}}) + +To access entries of these types, you must use a {{domxref("PerformanceObserver")}} instead. + ## Syntax ```js-nolint @@ -45,21 +55,17 @@ performance.mark("login-started"); performance.mark("login-finished"); performance.mark("form-sent"); performance.mark("video-loaded"); -performance.measure( - "login-duration", - "login-started", - "login-finished" - ); +performance.measure("login-duration", "login-started", "login-finished"); const entries = performance.getEntries(); entries.forEach((entry) => { if (entry.entryType === "mark") { console.log(`${entry.name}'s startTime: ${entry.startTime}`); - }; + } if (entry.entryType === "measure") { console.log(`${entry.name}'s duration: ${entry.duration}`); - }; + } }); ``` diff --git a/files/en-us/web/api/performance/getentriesbyname/index.md b/files/en-us/web/api/performance/getentriesbyname/index.md index 99b78e5c26cf545..4134981829536d8 100644 --- a/files/en-us/web/api/performance/getentriesbyname/index.md +++ b/files/en-us/web/api/performance/getentriesbyname/index.md @@ -19,6 +19,16 @@ If you are interested in performance entries of certain types, see {{domxref("Pe > **Note:** This method does not notify you about new performance entries; you will only get entries that are present in the performance timeline at the time you call this method. > To receive notifications about entries as they become available, use a {{domxref("PerformanceObserver")}}. +The following entry types are not supported by this method at all and won't be returned even if entries for these types might exist: + +- `"element"` ({{domxref("PerformanceElementTiming")}}) +- `"event"` ({{domxref("PerformanceEventTiming")}}) +- `"largest-contentful-paint"` ({{domxref("LargestContentfulPaint")}}) +- `"layout-shift"` ({{domxref("LayoutShift")}}) +- `"longtask"` ({{domxref("PerformanceLongTaskTiming")}}) + +To access entries of these types, you must use a {{domxref("PerformanceObserver")}} instead. + ## Syntax ```js-nolint diff --git a/files/en-us/web/api/performance/getentriesbytype/index.md b/files/en-us/web/api/performance/getentriesbytype/index.md index d6c4746fbd6ebe5..2c1e53bec1ffaf4 100644 --- a/files/en-us/web/api/performance/getentriesbytype/index.md +++ b/files/en-us/web/api/performance/getentriesbytype/index.md @@ -19,6 +19,16 @@ If you are interested in performance entries of certain name, see {{domxref("Per > **Note:** This method does not notify you about new performance entries; you will only get entries that are present in the performance timeline at the time you call this method. > To receive notifications about entries as they become available, use a {{domxref("PerformanceObserver")}}. +The following entry types are not supported by this method at all and won't be returned even if entries for these types might exist: + +- `"element"` ({{domxref("PerformanceElementTiming")}}) +- `"event"` ({{domxref("PerformanceEventTiming")}}) +- `"largest-contentful-paint"` ({{domxref("LargestContentfulPaint")}}) +- `"layout-shift"` ({{domxref("LayoutShift")}}) +- `"longtask"` ({{domxref("PerformanceLongTaskTiming")}}) + +To access entries of these types, you must use a {{domxref("PerformanceObserver")}} instead. + ## Syntax ```js-nolint