Skip to content

Commit

Permalink
Document limitations of performance.getEntries* methods (#22841)
Browse files Browse the repository at this point in the history
* Document limitations of performance.getEntries* methods

* Move out of note
  • Loading branch information
Elchi3 authored Dec 12, 2022
1 parent 5a35108 commit 7938403
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
20 changes: 13 additions & 7 deletions files/en-us/web/api/performance/getentries/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}`);
};
}
});
```

Expand Down
10 changes: 10 additions & 0 deletions files/en-us/web/api/performance/getentriesbyname/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions files/en-us/web/api/performance/getentriesbytype/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7938403

Please sign in to comment.