Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Long Tasks API pages #22927

Merged
merged 5 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8788,6 +8788,7 @@
/en-US/docs/Web/API/LockedFile/truncate /en-US/docs/Web/API/IDBFileHandle/truncate
/en-US/docs/Web/API/LockedFile/write /en-US/docs/Web/API/IDBFileHandle/write
/en-US/docs/Web/API/LongRange /en-US/docs/Web/API/MediaTrackConstraints
/en-US/docs/Web/API/Long_Tasks_API /en-US/docs/Web/API/PerformanceLongTaskTiming
/en-US/docs/Web/API/MIDIAccess/onstatechange /en-US/docs/Web/API/MIDIAccess/statechange_event
/en-US/docs/Web/API/MIDIInput/onmidimessage /en-US/docs/Web/API/MIDIInput/midimessage_event
/en-US/docs/Web/API/MIDIPort/onstatechange /en-US/docs/Web/API/MIDIPort/statechange_event
Expand Down
14 changes: 0 additions & 14 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -45413,20 +45413,6 @@
"modified": "2020-10-15T22:07:42.503Z",
"contributors": ["sideshowbarker", "Wuzzel", "jpmedley"]
},
"Web/API/Long_Tasks_API": {
"modified": "2020-10-15T21:54:38.944Z",
"contributors": [
"bradley27783",
"Wind1808",
"wbamberg",
"Sheppy",
"estelle",
"greglockwood",
"fscholz",
"tocretpa",
"jpmedley"
]
},
"Web/API/MIDIAccess": {
"modified": "2020-10-15T21:35:25.882Z",
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/glossary/first_input_delay/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tags:

It is the length of time, in milliseconds, between the first user interaction on a web page and the browser's response to that interaction. Scrolling and zooming are not included in this metric.

The time between when content is painted to the page and when all the functionality becomes responsive to human interaction often varies based on the size and complexity of the JavaScript needing to be downloaded, parsed, and executed on the main thread, and on the device speed or lack thereof (think low end mobile devices). The longer the delay, the worse the user experience. Reducing site initialization time and eliminating [long tasks](/en-US/docs/Web/API/Long_Tasks_API) can help eliminate first input delays.
The time between when content is painted to the page and when all the functionality becomes responsive to human interaction often varies based on the size and complexity of the JavaScript needing to be downloaded, parsed, and executed on the main thread, and on the device speed or lack thereof (think low end mobile devices). The longer the delay, the worse the user experience. Reducing site initialization time and eliminating [long tasks](/en-US/docs/Web/API/PerformanceLongTaskTiming) can help eliminate first input delays.

## See also

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/glossary/long_task/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ It is an uninterrupted period where the [main UI thread](/en-US/docs/Glossary/Ma

## See also

- [Long task API](/en-US/docs/Web/API/Long_Tasks_API)
- [Long task API](/en-US/docs/Web/API/PerformanceLongTaskTiming)
4 changes: 2 additions & 2 deletions files/en-us/glossary/time_to_interactive/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ tags:
- Web Performance
---

**Time to Interactive** (TTI) is a non-standardized web performance 'progress' metric defined as the point in time when the last [Long Task](/en-US/docs/Web/API/Long_Tasks_API) finished and was followed by 5 seconds of network and main thread inactivity.
**Time to Interactive** (TTI) is a non-standardized web performance 'progress' metric defined as the point in time when the last [Long Task](/en-US/docs/Web/API/PerformanceLongTaskTiming) finished and was followed by 5 seconds of network and main thread inactivity.

TTI, proposed by the Web Incubator Community Group in 2018, is intended to provide a metric that describes when a page or application contains useful content and the main thread is idle and free to respond to user interactions, including having event handlers registered.

#### Caveat

TTI is derived by leveraging information from the {{domxref("Long Tasks API")}}. Although available in some performance monitoring tools, TTI is not a part of any official web specification at the time of writing.
TTI is derived by leveraging information from the [Long Task API](/en-US/docs/Web/API/PerformanceLongTaskTiming). Although available in some performance monitoring tools, TTI is not a part of any official web specification at the time of writing.

## See also

Expand Down
91 changes: 0 additions & 91 deletions files/en-us/web/api/long_tasks_api/index.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ browser-compat: api.PerformanceLongTaskTiming.attribution

{{SeeCompatTable}}{{APIRef("Performance API")}}

The **`attribution`** readonly property of the
{{domxref("PerformanceLongTaskTiming")}} interface returns a sequence of
{{domxref('TaskAttributionTiming')}} instances.
The **`attribution`** readonly property of the {{domxref("PerformanceLongTaskTiming")}} interface returns an array of {{domxref('TaskAttributionTiming')}} objects.

## Value

A sequence of {{domxref('TaskAttributionTiming')}} instances.
An {{jsxref("Array")}} of {{domxref('TaskAttributionTiming')}} objects.

## Examples

### Logging attributions for long tasks

```js
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
entry.attribution.forEach((attributionEntry) => {
console.log(attributionEntry);
});
});
});

observer.observe({ type: "longtask", buffered: true });
```

## Specifications

Expand All @@ -22,3 +36,7 @@ A sequence of {{domxref('TaskAttributionTiming')}} instances.
## Browser compatibility

{{Compat}}

## See also

- {{domxref('TaskAttributionTiming')}}
67 changes: 66 additions & 1 deletion files/en-us/web/api/performancelongtasktiming/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,57 @@ browser-compat: api.PerformanceLongTaskTiming

{{SeeCompatTable}}{{APIRef("Performance API")}}

The **`PerformanceLongTaskTiming`** interface of the [Long Tasks API](/en-US/docs/Web/API/Long_Tasks_API) reports instances of long tasks.
The **`PerformanceLongTaskTiming`** interface provides information about tasks that occupy the UI thread for 50 milliseconds or more.

## Description

Long tasks that block the main thread for 50ms or more cause, among other issues:

- Delayed {{glossary("Time to interactive")}} (TTI).
- High/variable input latency.
- High/variable event handling latency.
- Janky animations and scrolling.

A long task is any uninterrupted period where the main UI thread is busy for 50ms or longer. Common examples include:

- Long-running event handlers.
- Expensive reflows and other re-renders.
- Work the browser does between different turns of the event loop that exceeds 50 ms.

Long tasks refer to "culprit browsing context container", or "the container" for short, which is the top-level page, {{HTMLElement("iframe")}}, {{HTMLElement("embed")}} or {{HTMLElement("object")}} that the task occurred within.

For tasks that don't occur within the top-level page and for figuring out which container is responsible for the long task, the {{domxref("TaskAttributionTiming")}} interface provides the `containerId`, `containerName` and `containerSrc` properties, which may provide more information about the source of the task.

## Inheritance

`PerformanceLongTaskTiming` inherits from {{domxref("PerformanceEntry")}}.

{{InheritanceDiagram}}

## Instance properties

This interface extends the following {{domxref("PerformanceEntry")}} properties for event timing performance entry types by qualifying them as follows:

- {{domxref("PerformanceEntry.duration")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns a {{domxref("DOMHighResTimeStamp")}} representing the elapsed time between the start and end of the task, with a 1ms granularity.
- {{domxref("PerformanceEntry.entryType")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Always returns `"longtask"`
- {{domxref("PerformanceEntry.name")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns one of the following strings referring to the browsing context or frame that can be attributed to the long task:
- `"cross-origin-ancestor"`
- `"cross-origin-descendant"`
- `"cross-origin-unreachable"`
- `"multiple-contexts"`
- `"same-origin-ancestor"`
- `"same-origin-descendant"`
- `"same-origin"`
- `"self"`
- `"unknown"`
- {{domxref("PerformanceEntry.startTime")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns a {{domxref("DOMHighResTimeStamp")}} representing the time when the task started.

This interface also supports the following properties:

- {{domxref("PerformanceLongTaskTiming.attribution")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns a sequence of {{domxref('TaskAttributionTiming')}} instances.

Expand All @@ -28,10 +73,30 @@ The **`PerformanceLongTaskTiming`** interface of the [Long Tasks API](/en-US/doc
- {{domxref("PerformanceLongTaskTiming.toJSON()")}} {{Experimental_Inline}}
- : Returns a JSON representation of the `PerformanceLongTaskTiming` object.

## Examples

### Getting long tasks

To get long task timing information, create a {{domxref("PerformanceObserver")}} instance and then call its [`observe()`](/en-US/docs/Web/API/PerformanceObserver/observe) method, passing in `"longtasks"` as the value of the [`type`](/en-US/docs/Web/API/PerformanceEntry/entryType) option. You also need to set `buffered` to `true` to get access to long tasks the user agent buffered while constructing the document. The `PerformanceObserver` object's callback will then be called with a list of `PerformanceLongTaskTiming` objects which you can analyze.

```js
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
console.log(entry);
});
});

observer.observe({ type: "longtask", buffered: true });
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("TaskAttributionTiming")}}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ browser-compat: api.TaskAttributionTiming.containerId

{{APIRef("Performance API")}}{{SeeCompatTable}}

The **`containerId`** readonly property of the
{{domxref("TaskAttributionTiming")}} interface returns the container's `id`
attribute. A container is the iframe, embed or object etc. that is being implicated, on
the whole, for a long task.
The **`containerId`** readonly property of the {{domxref("TaskAttributionTiming")}} interface returns the container's `id`
attribute. A container is the iframe, embed or object etc. that is being implicated, on the whole, for a long task.

## Value

A string containing the containers `id` attribute.
A string containing the container's [`id`](/en-US/docs/Web/HTML/Global_attributes/id) HTML content attribute.

## Specifications

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ browser-compat: api.TaskAttributionTiming.containerName

{{APIRef("Performance API")}}{{SeeCompatTable}}

The **`containerName`** readonly property of the
{{domxref("TaskAttributionTiming")}} interface returns the container's `name`
attribute. A container is the iframe, embed or object etc. that is being implicated, on
the whole, for a long task.
The **`containerName`** readonly property of the {{domxref("TaskAttributionTiming")}} interface returns the container's `name`
attribute. A container is the iframe, embed or object etc. that is being implicated, on the whole, for a long task.

## Value

A string containing the container's `name` attribute.
A string containing the container's `name` HTML content attribute (e.g. [`<iframe name="myIframe"`](/en-US/docs/Web/HTML/Element/iframe#attr-name) or [`<object name="myObject"`](/en-US/docs/Web/HTML/Element/object#attr-name)).

## Specifications

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ browser-compat: api.TaskAttributionTiming.containerSrc

{{APIRef("Performance API")}}{{SeeCompatTable}}

The **`containerSrc`** readonly property of the
{{domxref("TaskAttributionTiming")}} interface returns the container's `src`
attribute. A container is the iframe, embed or object etc. that is being implicated, on
the whole, for a long task.
The **`containerSrc`** readonly property of the {{domxref("TaskAttributionTiming")}} interface returns the container's `src`
attribute. A container is the iframe, embed or object etc. that is being implicated, on the whole, for a long task.

## Value

A string containing the container's `src` attribute.
A string containing the container's `src` attribute (e.g. [`<iframe src="url.html"`](/en-US/docs/Web/HTML/Element/iframe#attr-src)).

## Specifications

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ browser-compat: api.TaskAttributionTiming.containerType

{{APIRef("Performance API")}}{{SeeCompatTable}}

The **`containerType`** readonly property of the
{{domxref("TaskAttributionTiming")}} interface returns the type of frame container, one
of `iframe`, `embed`, or `object`.
The **`containerType`** readonly property of the {{domxref("TaskAttributionTiming")}} interface returns the type of the container, one of `iframe`, `embed`, or `object`.

## Value

A string containing the container's type, one of `iframe`,
`embed`, or `object`.
A string containing the container's type, one of `iframe`, `embed`, or `object`. If no type can be determined, `window` will be returned.

## Specifications

Expand Down
23 changes: 22 additions & 1 deletion files/en-us/web/api/taskattributiontiming/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,29 @@ browser-compat: api.TaskAttributionTiming

{{SeeCompatTable}}{{APIRef("Performance API")}}

The **`TaskAttributionTiming`** interface of the [Long Tasks API](/en-US/docs/Web/API/Long_Tasks_API) returns information about the work involved in a long task and its associate frame context. The frame context, also called the container, is the iframe, embed or object that is being implicated, on the whole, for a long task.
The **`TaskAttributionTiming`** interface returns information about the work involved in a long task and its associate frame context. The frame context, also called the container, is the iframe, embed or object that is being implicated, on the whole, for a long task.

You usually work with `TaskAttributionTiming` objects when observing [long tasks](/en-US/docs/Web/API/PerformanceLongTaskTiming).

`TaskAttributionTiming` inherits from {{domxref("PerformanceEntry")}}.

{{InheritanceDiagram}}

## Instance properties

This interface extends the following {{domxref("PerformanceEntry")}} properties for event timing performance entry types by qualifying them as follows:

- {{domxref("PerformanceEntry.duration")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Always returns `0`, as `duration` is not applicable for this interface.
- {{domxref("PerformanceEntry.entryType")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Always returns `taskattribution`.
- {{domxref("PerformanceEntry.name")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Always returns `"unknown"`.
- {{domxref("PerformanceEntry.startTime")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Always returns `0`.

This interface also supports the following properties:

- {{domxref('TaskAttributionTiming.containerType')}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns the type of frame container, one of `iframe`, `embed`, or `object`.
- {{domxref('TaskAttributionTiming.containerSrc')}} {{ReadOnlyInline}} {{Experimental_Inline}}
Expand All @@ -41,3 +58,7 @@ The **`TaskAttributionTiming`** interface of the [Long Tasks API](/en-US/docs/We
## Browser compatibility

{{Compat}}

## See also

- {{domxref("PerformanceLongTaskTiming")}}
1 change: 0 additions & 1 deletion files/en-us/web/performance/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ APIs
- [Navigator.deviceMemory](/en-US/docs/Web/API/Navigator/deviceMemory)
- [Intersection Observer](/en-US/docs/Web/API/Intersection_Observer_API)
- [Using the User Timing API](/en-US/docs/Web/API/User_Timing_API/Using_the_User_Timing_API)
- [Long Tasks API](/en-US/docs/Web/API/Long_Tasks_API)
- [High Resolution Timing API](/en-US/docs/Web/API/DOMHighResTimeStamp) ([https://w3c.github.io/hr-time/)](https://w3c.github.io/hr-time/)
- [Resource Timing API](/en-US/docs/Web/API/Resource_Timing_API/Using_the_Resource_Timing_API)
- [Page Visibility](/en-US/docs/Web/API/Page_Visibility_API)
Expand Down