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

Window.set/clearImmediate deprecated #29568

Merged
merged 1 commit into from
Oct 10, 2023
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
12 changes: 6 additions & 6 deletions files/en-us/web/api/window/clearimmediate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ title: "Window: clearImmediate() method"
short-title: clearImmediate()
slug: Web/API/Window/clearImmediate
page-type: web-api-instance-method
status:
- deprecated
- non-standard
browser-compat: api.Window.clearImmediate
---

{{APIRef("HTML DOM")}}
{{APIRef("HTML DOM")}} {{deprecated_header}}
Copy link
Collaborator Author

@hamishwillee hamishwillee Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, only one header gets applied - that's deprecated. I.e. deliberate omission.


This method clears the action specified by {{DOMxRef("window.setImmediate")}}.

> **Note:** This method is not expected to become standard, and is nowadays only implemented
> by Node.js 0.10+. It meets resistance both from [Gecko](https://bugzil.la/686201) (Firefox) and [Chromium/WebKit](https://crbug.com/146172) (Chrome/Safari).
## Syntax

```js-nolint
Expand Down Expand Up @@ -43,8 +43,8 @@ document.getElementById("button").addEventListener(() => {

## Specifications

Not part of any current specifications. The
[Efficient Script Yielding](https://w3c.github.io/setImmediate/#si-setImmediate)
Not part of any current specifications.
The [Efficient Script Yielding](https://w3c.github.io/setImmediate/#si-setImmediate)
specification is no longer being worked on.

## Browser compatibility
Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/api/window/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ _This interface inherits methods from the {{domxref("EventTarget")}} interface._
- : Enables you to cancel a callback previously scheduled with {{domxref("Window.requestAnimationFrame")}}.
- {{domxref("Window.cancelIdleCallback()")}}
- : Enables you to cancel a callback previously scheduled with {{domxref("Window.requestIdleCallback")}}.
- {{domxref("Window.clearImmediate()")}}
- {{domxref("Window.clearImmediate()")}} {{Non-standard_Inline}} {{Deprecated_Inline}}
- : Cancels the repeated execution set using `setImmediate()`.
- {{domxref("clearInterval", "Window.clearInterval()")}}
- : Cancels the repeated execution set using {{domxref("setInterval()")}}.
Expand Down Expand Up @@ -237,7 +237,7 @@ _This interface inherits methods from the {{domxref("EventTarget")}} interface._
- : Scrolls the current document by the specified number of pages.
- {{domxref("Window.scrollTo()")}}
- : Scrolls to a particular set of coordinates in the document.
- {{domxref("Window.setImmediate()")}}
- {{domxref("Window.setImmediate()")}} {{Non-standard_Inline}} {{Deprecated_Inline}}
- : Executes a function after the browser has finished other heavy tasks.
- {{domxref("setInterval", "Window.setInterval()")}}
- : Schedules a function to execute every time a given number of milliseconds elapses.
Expand Down
28 changes: 10 additions & 18 deletions files/en-us/web/api/window/setimmediate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ title: "Window: setImmediate() method"
short-title: setImmediate()
slug: Web/API/Window/setImmediate
page-type: web-api-instance-method
status:
- deprecated
- non-standard
browser-compat: api.Window.setImmediate
---

{{APIRef("HTML DOM")}}
{{APIRef("HTML DOM")}} {{deprecated_header}}

This method is used to break up long running operations and run a callback function
immediately after the browser has completed other operations such as events and display
updates.

> **Note:** This method is not expected to become standard, and is nowadays only implemented
> by Node.js 0.10+. It meets resistance both from [Gecko](https://bugzil.la/686201) (Firefox) and [Chromium/WebKit](https://crbug.com/146172) (Chrome/Safari).
This method is used to break up long running operations and run a callback function immediately after the browser has completed other operations such as events and display updates.

## Syntax

Expand All @@ -39,29 +37,23 @@ The ID of the immediate which can be used later with {{DOMxRef("window.clearImme

## Notes

The {{DOMxRef("Window.clearImmediate", "clearImmediate")}} method can be used to clear
the immediate actions, just like {{DOMxRef("clearTimeout")}} for
{{DOMxRef("setTimeout()")}}.
The {{DOMxRef("Window.clearImmediate", "clearImmediate")}} method can be used to clear the immediate actions, just like {{DOMxRef("clearTimeout")}} for {{DOMxRef("setTimeout()")}}.

This method can be used instead of the `setTimeout(fn, 0)` method to execute
[heavy operations](https://humanwhocodes.com/blog/2009/08/11/timed-array-processing-in-javascript/).
This method can be used instead of the `setTimeout(fn, 0)` method to execute [heavy operations](https://humanwhocodes.com/blog/2009/08/11/timed-array-processing-in-javascript/).

The feature can be emulated in a few different ways:

- {{DOMxRef("Window.postMessage", "postMessage")}} can be used to trigger an immediate but yielding callback.
- {{DOMxRef("MessageChannel")}} can be used reliably inside of Web Workers whereas the
semantics of postMessage mean it cannot be used there.
- `setTimeout(fn, 0)` _can_ potentially be used, however as it is
clamped to 4ms for timers nested more than 5 levels deep [per the HTML spec](https://html.spec.whatwg.org/multipage/webappapis.html#timers), it does not make for a suitable polyfill for the natural immediacy of
`setImmediate`.
- `setTimeout(fn, 0)` _can_ potentially be used, however as it is clamped to 4ms for timers nested more than 5 levels deep [per the HTML spec](https://html.spec.whatwg.org/multipage/webappapis.html#timers), it does not make for a suitable polyfill for the natural immediacy of `setImmediate`.

All of these techniques are incorporated into a [robust setImmediate polyfill](https://github.com/YuzuJS/setImmediate).

## Specifications

Not part of any current specifications. The
[Efficient Script Yielding](https://w3c.github.io/setImmediate/#si-setImmediate)
specification is no longer being worked on.
Not part of any current specifications.
The [Efficient Script Yielding](https://w3c.github.io/setImmediate/#si-setImmediate) specification is no longer being worked on.

## Browser compatibility

Expand Down