Document - Web APIs

Document
========

The **`Document`** interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.

The DOM tree includes elements such as `<body>` and `<table>`, among many others. It provides functionality globally to the document, like how to obtain the page's URL and create new elements in the document.

EventTarget

Node

Document
The `Document` interface describes the common properties and methods for any kind of document. Depending on the document's type (e.g. HTML, XML, SVG, …), a larger API is available: HTML documents, served with the `"text/html"` content type, also implement the `HTMLDocument` interface, whereas XML and SVG documents implement the `XMLDocument` interface.

Constructor
-----------

`Document()`

Creates a new `Document` object.

Instance properties
-------------------

*This interface also inherits from the `Node` and `EventTarget` interfaces.*

`Document.activeElement` Read only

Returns the `Element` that currently has focus.

`Document.adoptedStyleSheets`

 Add an array of constructed stylesheets to be used by the document.
 These stylesheets may also be shared with shadow DOM subtrees of the same document.

`Document.body`

Returns the `<body>` or `<frameset>` node of the current document.

`Document.characterSet` Read only

Returns the character set being used by the document.

`Document.childElementCount` Read only

Returns the number of child elements of the current document.

`Document.children` Read only

Returns the child elements of the current document.

`Document.compatMode` Read only

Indicates whether the document is rendered in *quirks* or *strict* mode.

`Document.contentType` Read only

Returns the Content-Type from the MIME Header of the current document.

`Document.currentScript` Read only

Returns the `<script>` element whose script is currently being processed and isn't a JavaScript module.

`Document.doctype` Read only

Returns the Document Type Definition (DTD) of the current document.

`Document.documentElement` Read only

Returns the `Element` that is a direct child of the document. For HTML documents, this is normally the `HTMLHtmlElement` object representing the document's `<html>` element.

`Document.documentURI` Read only

Returns the document location as a string.

`Document.embeds` Read only

Returns an `HTMLCollection` of the embedded `<embed>` elements in the document.

`Document.featurePolicy`
Experimental
 Read only

Returns the `FeaturePolicy` interface with the feature policies applied to the document.

`Document.firstElementChild` Read only

Returns the first child element of the current document.

`Document.fonts`

Returns the `FontFaceSet` interface of the current document.

`Document.forms` Read only

Returns an `HTMLCollection` of the `<form>` elements in the document.

`Document.fragmentDirective` Read only
Experimental

Returns the `FragmentDirective` for the current document.

`Document.fullscreenElement` Read only

The element that's currently in full screen mode for this document.

`Document.head` Read only

Returns the `<head>` element of the current document.

`Document.hidden` Read only

Returns a Boolean value indicating if the page is considered hidden or not.

`Document.images` Read only

Returns an `HTMLCollection` of the images in the document.

`Document.implementation` Read only

Returns the DOM implementation associated with the current document.

`Document.lastElementChild` Read only

Returns the last child element of the current document.

`Document.links` Read only

Returns an `HTMLCollection` of the hyperlinks in the document.

`Document.pictureInPictureElement` Read only

Returns the `Element` currently being presented in picture-in-picture mode in this document.

`Document.pictureInPictureEnabled` Read only

Returns true if the picture-in-picture feature is enabled.

`Document.plugins` Read only

Returns an `HTMLCollection` of the available plugins.

`Document.pointerLockElement` Read only

Returns the element set as the target for mouse events while the pointer is locked. `null` if lock is pending, pointer is unlocked, or if the target is in another document.

`Document.prerendering` Read only
Experimental

Returns a boolean that indicates whether the document is currently in the process of prerendering, as initiated via the Speculation Rules API.

`Document.scripts` Read only

Returns an `HTMLCollection` of the `<script>` elements in the document.

`Document.scrollingElement` Read only

Returns a reference to the `Element` that scrolls the document.

`Document.styleSheets` Read only

Returns a `StyleSheetList` of `CSSStyleSheet` objects for stylesheets explicitly linked into, or embedded in a document.

`Document.timeline` Read only

Returns timeline as a special instance of `DocumentTimeline` that is automatically created on page load.

`Document.visibilityState` Read only

Returns a `string` denoting the visibility state of the document. Possible values are `visible`, `hidden`, `prerender`, and `unloaded`.

### Extensions for HTMLDocument

*The `Document` interface for HTML documents inherits from the `HTMLDocument` interface or is extended for such documents.*

`Document.cookie`

Returns a semicolon-separated list of the cookies for that document or sets a single cookie.

`Document.defaultView` Read only

Returns a reference to the window object.

`Document.designMode`

Gets/sets the ability to edit the whole document.

`Document.dir`

Gets/sets directionality (rtl/ltr) of the document.

`Document.fullscreenEnabled` Read only

Indicates whether fullscreen mode is available.

`Document.lastModified` Read only

Returns the date on which the document was last modified.

`Document.location` Read only

Returns the URI of the current document.

`Document.readyState` Read only

Returns loading status of the document.

`Document.referrer` Read only

Returns the URI of the page that linked to this page.

`Document.title`

Sets or gets the title of the current document.

`Document.URL` Read only

Returns the document location as a string.

### Deprecated properties

`Document.alinkColor`
Deprecated

Returns or sets the color of active links in the document body.

`Document.all`
Deprecated

Provides access to all elements in the document — it returns an `HTMLAllCollection` rooted at the document node. This is a legacy, non-standard property and should not be used.

`Document.anchors`
Deprecated
 Read only

Returns a list of all of the anchors in the document.

`Document.applets`
Deprecated
 Read only

Returns an empty `HTMLCollection`. Legacy property that used to return the list of applets within a document.

`Document.bgColor`
Deprecated

Gets/sets the background color of the current document.

`Document.charset`
Deprecated
 Read only

Alias of `Document.characterSet`. Use this property instead.

`Document.domain`
Deprecated

Gets/sets the domain of the current document.

`Document.fgColor`
Deprecated

Gets/sets the foreground color, or text color, of the current document.

`Document.fullscreen`
Deprecated

Returns `true` when the document is in fullscreen mode.

`Document.inputEncoding`
Deprecated
 Read only

Alias of `Document.characterSet`. Use this property instead.

`Document.lastStyleSheetSet`
Deprecated
 Read only
Non-standard

Returns the name of the style sheet set that was last enabled. Has the value `null` until the style sheet is changed by setting the value of `selectedStyleSheetSet`.

`Document.linkColor`
Deprecated

Gets/sets the color of hyperlinks in the document.

`Document.preferredStyleSheetSet`
Deprecated
 Read only
Non-standard

Returns the preferred style sheet set as specified by the page author.

`Document.rootElement`
Deprecated

Like `Document.documentElement`, but only for `<svg>` root elements. Use this property instead.

`Document.selectedStyleSheetSet`
Deprecated

Non-standard

Returns which style sheet set is currently in use.

`Document.styleSheetSets`
Deprecated
 Read only
Non-standard

Returns a list of the style sheet sets available on the document.

`Document.vlinkColor`
Deprecated

Gets/sets the color of visited hyperlinks.

`Document.xmlEncoding`
Deprecated

Returns the encoding as determined by the XML declaration.

`Document.xmlStandalone`
Deprecated

Returns `true` if the XML declaration specifies the document to be standalone (*e.g.,* An external part of the DTD affects the document's content), else `false`.

`Document.xmlVersion`
Deprecated

Returns the version number as specified in the XML declaration or `"1.0"` if the declaration is absent.

Instance methods
----------------

*This interface also inherits from the `Node` and `EventTarget` interfaces.*

`Document.adoptNode()`

Adopt node from an external document.

`Document.append()`

Inserts a set of `Node` objects or string objects after the last child of the document.

`Document.captureEvents()`
Deprecated

See `Window.captureEvents`.

`Document.caretPositionFromPoint()`

Returns a `CaretPosition` object containing the DOM node containing the caret, and caret's character offset within that node.

`Document.caretRangeFromPoint()`
Non-standard

Gets a `Range` object for the document fragment under the specified coordinates.

`Document.createAttribute()`

Creates a new `Attr` object and returns it.

`Document.createAttributeNS()`

Creates a new attribute node in a given namespace and returns it.

`Document.createCDATASection()`

Creates a new CDATA node and returns it.

`Document.createComment()`

Creates a new comment node and returns it.

`Document.createDocumentFragment()`

Creates a new document fragment.

`Document.createElement()`

Creates a new element with the given tag name.

`Document.createElementNS()`

Creates a new element with the given tag name and namespace URI.

`Document.createEvent()`

Creates an event object.

`Document.createNodeIterator()`

Creates a `NodeIterator` object.

`Document.createProcessingInstruction()`

Creates a new `ProcessingInstruction` object.

`Document.createRange()`

Creates a `Range` object.

`Document.createTextNode()`

Creates a text node.

`Document.createTouch()`
Deprecated

Non-standard

Creates a `Touch` object.

`Document.createTouchList()`
Deprecated

Non-standard

Creates a `TouchList` object.

`Document.createTreeWalker()`

Creates a `TreeWalker` object.

`Document.elementFromPoint()`

Returns the topmost element at the specified coordinates.

`Document.elementsFromPoint()`

Returns an array of all elements at the specified coordinates.

`Document.enableStyleSheetsForSet()`
Deprecated

Non-standard

Enables the style sheets for the specified style sheet set.

`Document.exitFullscreen()`

Stops document's fullscreen element from being displayed fullscreen.

`Document.exitPictureInPicture()`

Remove the video from the floating picture-in-picture window back to its original container.

`Document.exitPointerLock()`

Release the pointer lock.

`Document.getAnimations()`

Returns an array of all `Animation` objects currently in effect, whose target elements are descendants of the `document`.

`Document.getBoxQuads()`
Experimental

Returns a list of `DOMQuad` objects representing the CSS fragments of the node.

`Document.getElementById()`

Returns an object reference to the identified element.

`Document.getElementsByClassName()`

Returns a list of elements with the given class name.

`Document.getElementsByTagName()`

Returns a list of elements with the given tag name.

`Document.getElementsByTagNameNS()`

Returns a list of elements with the given tag name and namespace.

`Document.getSelection()`

Returns a `Selection` object representing the range of text selected by the user, or the current position of the caret.

`Document.hasStorageAccess()`

Returns a `Promise` that resolves with a boolean value indicating whether the document has access to unpartitioned cookies.

`Document.importNode()`

Returns a clone of a node from an external document.

`Document.mozSetImageElement()`
Non-standard

Allows you to change the element being used as the background image for a specified element ID.

`Document.prepend()`

Inserts a set of `Node` objects or string objects before the first child of the document.

`Document.querySelector()`

Returns the first Element node within the document, in document order, that matches the specified selectors.

`Document.querySelectorAll()`

Returns a list of all the Element nodes within the document that match the specified selectors.

`Document.releaseCapture()`
Non-standard

Releases the current mouse capture if it's on an element in this document.

`Document.releaseEvents()`
Deprecated

See `Window.releaseEvents()`.

`Document.replaceChildren()`

Replaces the existing children of a document with a specified new set of children.

`Document.requestStorageAccess()`

Allows a document loaded in a third-party context (i.e. embedded in an `<iframe>`) to request access to unpartitioned cookies, in cases where user agents by default block access to unpartitioned cookies by sites loaded in a third-party context to improve privacy.

`Document.requestStorageAccessFor()`
Experimental

Allows top-level sites to request third-party cookie access on behalf of embedded content originating from another site in the same related website set.

`Document.startViewTransition()`
Experimental

Starts a new view transition and returns a `ViewTransition` object to represent it.

The `Document` interface is extended with the `XPathEvaluator` interface:

`Document.createExpression()`

Compiles an `XPathExpression` which can then be used for (repeated) evaluations.

`Document.createNSResolver()`

Creates an `XPathNSResolver` object.

`Document.evaluate()`

Evaluates an XPath expression.

### Extension for HTML documents

The `Document` interface for HTML documents inherit from the `HTMLDocument` interface or is extended for such documents:

`Document.clear()`
Deprecated

This method does nothing.

`Document.close()`

Closes a document stream for writing.

`Document.execCommand()`
Deprecated

On an editable document, executes a formatting command.

`Document.getElementsByName()`

Returns a list of elements with the given name.

`Document.hasFocus()`

Returns `true` if the focus is currently located anywhere inside the specified document.

`Document.open()`

Opens a document stream for writing.

`Document.queryCommandEnabled()`
Deprecated

Non-standard

Returns true if the formatting command can be executed on the current range.

`Document.queryCommandIndeterm()`
Deprecated

Returns true if the formatting command is in an indeterminate state on the current range.

`Document.queryCommandState()`
Deprecated

Non-standard

Returns true if the formatting command has been executed on the current range.

`Document.queryCommandSupported()`
Deprecated

Non-standard

Returns true if the formatting command is supported on the current range.

`Document.queryCommandValue()`
Deprecated

Returns the current value of the current range for a formatting command.

`Document.write()`

Writes text in a document.

`Document.writeln()`

Writes a line of text in a document.

Events
------

Listen to these events using `addEventListener()` or by assigning an event listener to the `oneventname` property of this interface. In addition to the events listed below, many events can bubble from nodes contained in the document tree.

`afterscriptexecute`
Non-standard

Fired when a static `<script>` element finishes executing its script

`beforescriptexecute`
Non-standard

Fired when a static `<script>` is about to start executing.

`prerenderingchange`
Experimental

Fired on a prerendered document when it is activated (i.e. the user views the page).

`securitypolicyviolation`

Fired when a content security policy is violated.

`visibilitychange`

Fired when the content of a tab has become visible or has been hidden.

### Clipboard events

`copy`

Fired when the user initiates a copy action through the browser's user interface.

`cut`

Fired when the user initiates a cut action through the browser's user interface.

`paste`

Fired when the user initiates a paste action through the browser's user interface.

### Fullscreen events

`fullscreenchange`

Fired when the `Document` transitions into or out of fullscreen mode.

`fullscreenerror`

Fired if an error occurs while attempting to switch into or out of fullscreen mode.

### Load & unload events

`DOMContentLoaded`

Fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.

`readystatechange`

Fired when the `readyState` attribute of a document has changed.

### Pointer lock events

`pointerlockchange`

Fired when the pointer is locked/unlocked.

`pointerlockerror`

Fired when locking the pointer failed.

### Scroll events

`scroll`

Fired when the document view or an element has been scrolled.

`scrollend`

Fired when the document view or an element has been scrolled.

### Selection events

`selectionchange`

Fired when the current text selection on a document is changed.

Specifications
--------------

| Specification |
| --- |
| DOM Standard # interface-document |
| HTML Standard # the-document-object |
| CSSOM View Module # extensions-to-the-document-interface |
| Pointer Lock 2.0 # extensions-to-the-document-interface |
| Selection API # extensions-to-document-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


HTMLSpanElement - Web APIs

HTMLSpanElement
===============

The **`HTMLSpanElement`** interface represents a `<span>` element and derives from the `HTMLElement` interface, but without implementing any additional properties or methods.

EventTarget

Node

Element

HTMLElement

HTMLSpanElementInstance properties
-------------------

*This interface has no properties, but inherits properties from: `HTMLElement`.*

Instance methods
----------------

*This interface has no methods, but inherits methods from: `HTMLElement`.*

Specifications
--------------

| Specification |
| --- |
| HTML Standard # htmlspanelement |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* The HTML element implementing this interface: `<span>`.


Plugin - Web APIs

Plugin
======

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

The `Plugin` interface provides information about a browser plugin.

**Note:** Own properties of `Plugin` objects are no longer enumerable in the latest browser versions.

Instance properties
-------------------

`Plugin.description` Read only
Deprecated

A human-readable description of the plugin.

`Plugin.filename` Read only
Deprecated

The filename of the plugin file.

`Plugin.name` Read only
Deprecated

The name of the plugin.

Instance methods
----------------

`Plugin.item`
Deprecated

Returns the MIME type of a supported content type, given the index number into a list of supported types.

`Plugin.namedItem`
Deprecated

Returns the MIME type of a supported item.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-plugin |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


AesKeyGenParams - Web APIs

AesKeyGenParams
===============

The **`AesKeyGenParams`** dictionary of the Web Crypto API represents the object that should be passed as the `algorithm` parameter into `SubtleCrypto.generateKey()`, when generating an AES key: that is, when the algorithm is identified as any of AES-CBC, AES-CTR, AES-GCM, or AES-KW.

Instance properties
-------------------

`name`

A string. This should be set to `AES-CBC`, `AES-CTR`, `AES-GCM`, or `AES-KW`, depending on the algorithm you want to use.

`length`

A `Number` — the length in bits of the key to generate. This must be one of: 128, 192, or 256.

Examples
--------

See the examples for `SubtleCrypto.generateKey()`.

Specifications
--------------

| Specification |
| --- |
| Web Cryptography API # dfn-AesKeyGenParams |

Browser compatibility
---------------------

Browsers that support any of the AES-based algorithms for the `SubtleCrypto.generateKey()` method will support this type.

See also
--------

* `SubtleCrypto.generateKey()`.


PresentationConnection - Web APIs

PresentationConnection
======================

**Experimental:** **This is an experimental technology**
Check the Browser compatibility table carefully before using this in production.

**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The **`PresentationConnection`** interface of the Presentation API provides methods and properties for managing a single presentation. Each presentation connection is represented by a `PresentationConnection` object. Both the controlling user agent and receiving user agent *MUST* implement `PresentationConnection`.

EventTarget

PresentationConnectionInstance properties
-------------------

`PresentationConnection.binaryType`
Experimental

Returns either blob or arrayBuffer. When a `PresentationConnection` object is created, its `binaryType` IDL attribute *MUST* be set to the string " `arraybuffer`".

`PresentationConnection.id` Read only
Experimental

Provides the presentation connection identifier.

`PresentationConnection.state` Read only
Experimental

Returns the presentation connection's current state.

`PresentationConnection.url` Read only
Experimental

Returns the URL used to create or reconnect to the presentation.

### Event handlers

`PresentationConnection.onclose`
Experimental

Fired when there is a call to `PresentationConnection.close()`.

`PresentationConnection.onconnect`
Experimental

Fired when a presentation connection is established.

`PresentationConnection.onmessage`
Experimental

Fired when there is a call to `PresentationConnection.send()`.

`PresentationConnection.onterminated`

Fired when there is a call to `PresentationConnection.terminate()`.

Instance methods
----------------

`PresentationConnection.close()`
Experimental

Closes the current connection and sends a `PresentationConnectionCloseEvent` to `PresentationConnection.onclosed`.

`PresentationConnection.send()`
Experimental

Sends either binary or text data between a controlling browsing context and a presenting browsing context.

`PresentationConnection.terminate()`
Experimental

Terminates the current connection and fires `PresentationConnection.onterminated`.

Specifications
--------------

| Specification |
| --- |
| Presentation API # interface-presentationconnection |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


Sanitizer - Web APIs

Sanitizer
=========

**Experimental:** **This is an experimental technology**
Check the Browser compatibility table carefully before using this in production.

**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

 The **`Sanitizer`** interface of the `HTML Sanitizer API` is used to sanitize untrusted strings of HTML, `Document` and `DocumentFragment` objects.
 After sanitization, unwanted elements or attributes are removed, and the returned objects can safely be inserted into a document's DOM.

A **`Sanitizer`** object is also used by the `Element.setHTML()` method to parse and sanitize a string of HTML, and immediately insert it into an element.

 The default configuration strips out XSS-relevant input by default, including `<script>` tags, custom elements, and comments.
 This configuration may be customized using constructor options.

Constructors
------------

`Sanitizer()`
Experimental

Creates and returns a `Sanitizer` object, optionally with custom sanitization behavior.

Instance methods
----------------

`Sanitizer.sanitize()`
Experimental

Returns a sanitized `DocumentFragment` from an input `Document` or `DocumentFragment`

Examples
--------

For examples see the `HTML Sanitizer API` and the individual methods.

Specifications
--------------

| Specification |
| --- |
| HTML Sanitizer API # sanitizer-api |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


HTMLOutputElement - Web APIs

HTMLOutputElement
=================

The **`HTMLOutputElement`** interface provides properties and methods (beyond those inherited from `HTMLElement`) for manipulating the layout and presentation of `<output>` elements.

EventTarget

Node

Element

HTMLElement

HTMLOutputElementInstance properties
-------------------

*This interface also inherits properties from its parent, `HTMLElement`.*

`HTMLOutputElement.defaultValue`

A string representing the default value of the element, initially the empty string.

`HTMLOutputElement.form` Read only

An `HTMLFormElement` indicating the form associated with the control, reflecting the `form` HTML attribute if it is defined.

`HTMLOutputElement.htmlFor` Read only

A `DOMTokenList` reflecting the `for` HTML attribute, containing a list of IDs of other elements in the same document that contribute to (or otherwise affect) the calculated `value`.

`HTMLOutputElement.labels` Read only

A `NodeList` of `<label>` elements associated with the element.

`HTMLOutputElement.name`

A string reflecting the `name` HTML attribute, containing the name for the control that is submitted with form data.

`HTMLOutputElement.type` Read only

The string "`output`".

`HTMLOutputElement.validationMessage` Read only

A string representing a localized message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation (`willValidate` is `false`), or it satisfies its constraints.

`HTMLOutputElement.validity` Read only

A `ValidityState` representing the validity states that this element is in.

`HTMLOutputElement.value`

A string representing the value of the contents of the elements. Behaves like the `Node.textContent` property.

`HTMLOutputElement.willValidate` Read only

A boolean value indicating whether the element is a candidate for constraint validation.

Instance methods
----------------

*This interface also inherits methods from its parent, `HTMLElement`.*

`HTMLOutputElement.checkValidity()`

Checks the validity of the element and returns a boolean value holding the check result.

`HTMLOutputElement.reportValidity()`

This method reports the problems with the constraints on the element, if any, to the user. If there are problems, fires an `invalid` event at the element, and returns `false`; if there are no problems, it returns `true`.

When the problem is reported, the user agent may focus the element and change the scrolling position of the document or perform some other action that brings the element to the user's attention. User agents may report more than one constraint violation if this element suffers from multiple problems at once. If the element is not rendered, then the user agent may report the error for the running script instead of notifying the user.

`HTMLOutputElement.setCustomValidity()`

Sets a custom validity message for the element. If this message is not the empty string, then the element is suffering from a custom validity error, and does not validate.

Modes
-----

This element behaves in one of two modes: *default* mode and *value* mode.

### Default mode

Initially, the element is in default mode, and so the contents of the element represent both the value of the element and its default value.

If the element is in default mode when the descendants of the element are changed in any way, the `defaultValue` property is set to the value of the `textContent` property.

Resetting the form puts the element into default mode, and sets the `textContent` property to the value of the `defaultValue` property.

### Value mode

The element goes into value mode when the contents of the `value` property are set. The `value` property otherwise behaves like the `textContent` property. When the element is in value mode, the default value is accessible only through the `defaultValue` property.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # htmloutputelement |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* The HTML element implementing this interface: `<output>`.


CSSUnparsedValue - Web APIs

CSSUnparsedValue
================

The **`CSSUnparsedValue`** interface of the CSS\_Object\_Model#css\_typed\_object\_model represents property values that reference custom properties. It consists of a list of string fragments and variable references.

Custom properties are represented by `CSSUnparsedValue` and `var()` references are represented using `CSSVariableReferenceValue`.

CSSStyleValue

CSSUnparsedValueConstructor
-----------

`CSSUnparsedValue()`

Creates a new `CSSUnparsedValue` object.

Instance properties
-------------------

`CSSUnparsedValue.length`

Returns the number of items in the `CSSUnparsedValue` object.

Instance methods
----------------

`CSSUnparsedValue.entries()`

Returns an array of a given object's own enumerable property `[key, value]` pairs in the same order as that provided by a `for...in` loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).

`CSSUnparsedValue.forEach()`

Executes a provided function once for each element of the `CSSUnparsedValue` object.

`CSSUnparsedValue.keys()`

Returns a new *array iterator* object that contains the keys for each index in the `CSSUnparsedValue` object.

`CSSUnparsedValue.values()`

Returns a new *array iterator* object that contains the values for each index in the `CSSUnparsedValue` object.

Specifications
--------------

| Specification |
| --- |
| CSS Typed OM Level 1 # cssunparsedvalue |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `CSSImageValue`
* `CSSKeywordValue`
* `CSSNumericValue`
* `CSSPositionValue`
* `CSSTransformValue`
* Using the CSS Typed OM
* CSS Typed Object Model API


EXT_texture_compression_rgtc extension - Web APIs

EXT\_texture\_compression\_rgtc extension
=========================================

The `EXT_texture_compression_rgtc` extension is part of the WebGL API and exposes 4 RGTC compressed texture formats. RGTC is a block-based texture compression format suited for unsigned and signed red and red-green textures (**R**ed-**G**reen **T**exture **C**ompression).

WebGL extensions are available using the `WebGLRenderingContext.getExtension()` method. For more information, see also Using Extensions in the WebGL tutorial.

**Note:** Support depends on the system's graphics driver. There is no support on Windows.

This extension is available to both, WebGL1 and WebGL2 contexts.

Constants
---------

The compressed texture formats are exposed by 4 constants and can be used in two functions: `compressedTexImage2D()` and `compressedTexSubImage2D()`.

`ext.COMPRESSED_RED_RGTC1_EXT`

Each 4x4 block of texels consists of 64 bits of unsigned red image data. See also BC4 unsigned.

`ext.COMPRESSED_SIGNED_RED_RGTC1_EXT`

Each 4x4 block of texels consists of 64 bits of signed red image data. See also BC4 signed.

`ext.COMPRESSED_RED_GREEN_RGTC2_EXT`

Each 4x4 block of texels consists of 64 bits of compressed unsigned red image data followed by 64 bits of compressed unsigned green image data. See also BC5 unsigned.

`ext.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT`

Each 4x4 block of texels consists of 64 bits of compressed signed red image data followed by 64 bits of compressed signed green image data. See also BC5 signed.

Examples
--------

```js
const ext = gl.getExtension("EXT\_texture\_compression\_rgtc");

const texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE\_2D, texture);

gl.compressedTexImage2D(
  gl.TEXTURE\_2D,
  0,
  ext.COMPRESSED\_RED\_RGTC1\_EXT,
  128,
  128,
  0,
  textureData,
);
```

Specifications
--------------

| Specification |
| --- |
| WebGL EXT\_texture\_compression\_rgtc Extension Specification  |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.getExtension()`
* `WebGLRenderingContext.compressedTexImage2D()`
* `WebGLRenderingContext.compressedTexSubImage2D()`
* `WebGLRenderingContext.getParameter()`


XRBoundedReferenceSpace - Web APIs

XRBoundedReferenceSpace
=======================

**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

**Experimental:** **This is an experimental technology**
Check the Browser compatibility table carefully before using this in production.

The WebXR Device API's **`XRBoundedReferenceSpace`** interface describes a virtual world reference space which has preset boundaries. This extends `XRReferenceSpace`, which describes an essentially unrestricted space around the viewer's position. These bounds are defined using an array of points, each of which defines a vertex in a polygon inside which the user is allowed to move.

This is typically used when the XR system is capable of tracking the user's physical movement within a limited distance of their starting position. The specified bounds may, in fact, describe the shape and size of the room the user is located in, in order to let the WebXR site or application prevent the user from colliding with the walls or other obstacles in the real world. At a minimum, the boundaries indicate the area in which the XR device is capable of tracking the user's movement. See the article Using bounded reference spaces for details on how bounded spaces work and why they're useful.

EventTarget

XRSpace

XRReferenceSpace

XRBoundedReferenceSpaceInstance properties
-------------------

*In addition to the properties of `XRReferenceSpace`, `XRBoundedReferenceSpace` includes the following:*

`boundsGeometry` Read only
Experimental

An array of `DOMPointReadOnly` objects, each of which defines a vertex in the polygon defining the boundaries within which the user will be required to remain. These vertices *must* be sorted such that they move *clockwise* around the viewer's position.

Instance methods
----------------

*`XRBoundedReferenceSpace` inherits the methods of its parent interface, `XRReferenceSpace`. It has no further methods.*

Specifications
--------------

| Specification |
| --- |
| WebXR Device API # xrboundedreferencespace-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* WebXR Device API
* Geometry and reference spaces in WebXR
* Viewpoints and viewers: simulating cameras in WebXR


CryptoKey - Web APIs

CryptoKey
=========

**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The **`CryptoKey`** interface of the Web Crypto API represents a cryptographic key obtained from one of the `SubtleCrypto` methods `generateKey()`, `deriveKey()`, `importKey()`, or `unwrapKey()`.

For security reasons, the `CryptoKey` interface can only be used in a secure context.

Instance properties
-------------------

`CryptoKey.type` Read only

The type of key the object represents. It may take one of the following values: `"secret"`, `"private"` or `"public"`.

`CryptoKey.extractable` Read only

A boolean value indicating whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`.

`CryptoKey.algorithm` Read only

An object describing the algorithm for which this key can be used and any associated extra parameters.

`CryptoKey.usages` Read only

An `Array` of strings, indicating what can be done with the key. Possible values for array elements are `"encrypt"`, `"decrypt"`, `"sign"`, `"verify"`, `"deriveKey"`, `"deriveBits"`, `"wrapKey"`, and `"unwrapKey"`.

Examples
--------

The examples for `SubtleCrypto` methods often use `CryptoKey` objects. For example:

* `SubtleCrypto.generateKey()`
* `SubtleCrypto.deriveKey()`
* `SubtleCrypto.importKey()`
* `SubtleCrypto.exportKey()`
* `SubtleCrypto.wrapKey()`
* `SubtleCrypto.unwrapKey()`
* `SubtleCrypto.encrypt()`
* `SubtleCrypto.decrypt()`
* `SubtleCrypto.sign()`
* `SubtleCrypto.verify()`
Specifications
--------------

| Specification |
| --- |
| Web Cryptography API # cryptokey-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Crypto API
* Web security
* Privacy, permissions, and information security
* `Crypto` and `Crypto.subtle`.


PushEvent - Web APIs

PushEvent
=========

The **`PushEvent`** interface of the Push API represents a push message that has been received. This event is sent to the global scope of a `ServiceWorker`. It contains the information sent from an application server to a `PushSubscription`.

Event

ExtendableEvent

PushEventConstructor
-----------

`PushEvent()`

Creates a new `PushEvent` object.

Instance properties
-------------------

*Inherits properties from its parent, `ExtendableEvent`. Additional properties:*

`PushEvent.data` Read only

Returns a reference to a `PushMessageData` object containing data sent to the `PushSubscription`.

Instance methods
----------------

*Inherits methods from its parent, `ExtendableEvent`*.

Examples
--------

The following example takes data from a `PushEvent` and displays it on all of the service worker's clients.

```js
self.addEventListener("push", (event) => {
  if (!(self.Notification && self.Notification.permission === "granted")) {
    return;
  }

  const data = event.data?.json() ?? {};
  const title = data.title || "Something Has Happened";
  const message =
    data.message || "Here's something you might want to check out.";
  const icon = "images/new-notification.png";

  const notification = new self.Notification(title, {
    body: message,
    tag: "simple-push-demo-notification",
    icon,
  });

  notification.addEventListener("click", () => {
    clients.openWindow(
      "https://example.blog.com/2015/03/04/something-new.html",
    );
  });
});
```

Specifications
--------------

| Specification |
| --- |
| Push API # pushevent-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Push API
* Service Worker API


CSSNamespaceRule - Web APIs

CSSNamespaceRule
================

The **`CSSNamespaceRule`** interface describes an object representing a single CSS `@namespace` at-rule.

CSSRule

CSSNamespaceRuleInstance properties
-------------------

*Inherits properties from its ancestor `CSSRule`.*

`CSSNamespaceRule.namespaceURI`

Returns a string containing the text of the URI of the given namespace.

`CSSNamespaceRule.prefix`

Returns a string with the name of the prefix associated to this namespace. If there is no such prefix, returns an empty string.

Instance methods
----------------

*Inherits methods from its ancestor `CSSRule`.*

Examples
--------

The stylesheet includes a namespace as the only rule. Therefore the first `CSSRule` returned will be a `CSSNamespaceRule`.

```css
@namespace url(http://www.w3.org/1999/xhtml);
```

```js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); //a CSSNamespaceRule
```

Specifications
--------------

| Specification |
| --- |
| CSS Object Model (CSSOM) # the-cssnamespacerule-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


Cache - Web APIs

Cache
=====

The **`Cache`** interface provides a persistent storage mechanism for `Request` / `Response` object pairs that are cached in long lived memory. How long a `Cache` object lives is browser dependent, but a single origin's scripts can typically rely on the presence of a previously populated `Cache` object. Note that the `Cache` interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec.

An origin can have multiple, named `Cache` objects. You are responsible for implementing how your script (e.g. in a `ServiceWorker`) handles `Cache` updates. Items in a `Cache` do not get updated unless explicitly requested; they don't expire unless deleted. Use `CacheStorage.open()` to open a specific named `Cache` object and then call any of the `Cache` methods to maintain the `Cache`.

You are also responsible for periodically purging cache entries. Each browser has a hard limit on the amount of cache storage that a given origin can use. `Cache` quota usage estimates are available via the `StorageManager.estimate()` method. The browser does its best to manage disk space, but it may delete the `Cache` storage for an origin. The browser will generally delete all of the data for an origin or none of the data for an origin. Make sure to version caches by name and use the caches only from the version of the script that they can safely operate on. See Deleting old caches for more information.

**Note:** The key matching algorithm depends on the VARY header in the value. So matching a new key requires looking at both key and value for entries in the `Cache` object.

**Note:** The caching API doesn't honor HTTP caching headers.

**Note:** This feature is available in Web Workers

**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Instance methods
----------------

`Cache.match(request, options)`

Returns a `Promise` that resolves to the response associated with the first matching request in the `Cache` object.

`Cache.matchAll(request, options)`

Returns a `Promise` that resolves to an array of all matching responses in the `Cache` object.

`Cache.add(request)`

Takes a URL, retrieves it and adds the resulting response object to the given cache. This is functionally equivalent to calling `fetch()`, then using `put()` to add the results to the cache.

`Cache.addAll(requests)`

Takes an array of URLs, retrieves them, and adds the resulting response objects to the given cache.

`Cache.put(request, response)`

Takes both a request and its response and adds it to the given cache.

`Cache.delete(request, options)`

Finds the `Cache` entry whose key is the request, returning a `Promise` that resolves to `true` if a matching `Cache` entry is found and deleted. If no `Cache` entry is found, the promise resolves to `false`.

`Cache.keys(request, options)`

Returns a `Promise` that resolves to an array of `Cache` keys.

Examples
--------

This code snippet is from the service worker selective caching sample. (see selective caching live) The code uses `CacheStorage.open()` to open any `Cache` objects with a `Content-Type` header that starts with `font/`.

The code then uses `Cache.match()` to see if there's already a matching font in the cache, and if so, returns it. If there isn't a matching font, the code fetches the font from the network and uses `Cache.put()` to cache the fetched resource.

The code handles exceptions thrown from the `fetch()` operation. Note that an HTTP error response (e.g., 404) will not trigger an exception. It will return a normal response object that has the appropriate error code.

The code snippet also shows a best practice for versioning caches used by the service worker. Though there's only one cache in this example, the same approach can be used for multiple caches. It maps a shorthand identifier for a cache to a specific, versioned cache name. The code also deletes all caches that aren't named in `CURRENT_CACHES`.

In the code example, `caches` is a property of the `ServiceWorkerGlobalScope`. It holds the `CacheStorage` object, by which it can access the `CacheStorage` interface.

**Note:** In Chrome, visit `chrome://inspect/#service-workers` and click on the "inspect" link below the registered service worker to view logging statements for the various actions the `service-worker.js` script is performing.

```js
const CACHE\_VERSION = 1;
const CURRENT\_CACHES = {
  font: `font-cache-v${CACHE\_VERSION}`,
};

self.addEventListener("activate", (event) => {
  // Delete all caches that aren't named in CURRENT\_CACHES.
  // While there is only one cache in this example, the same logic
  // will handle the case where there are multiple versioned caches.
  const expectedCacheNamesSet = new Set(Object.values(CURRENT\_CACHES));
  event.waitUntil(
    caches.keys().then((cacheNames) =>
      Promise.all(
        cacheNames.map((cacheName) => {
          if (!expectedCacheNamesSet.has(cacheName)) {
            // If this cache name isn't present in the set of
            // "expected" cache names, then delete it.
            console.log("Deleting out of date cache:", cacheName);
            return caches.delete(cacheName);
          }
        }),
      ),
    ),
  );
});

self.addEventListener("fetch", (event) => {
  console.log("Handling fetch event for", event.request.url);

  event.respondWith(
    caches.open(CURRENT\_CACHES.font).then((cache) => {
      return cache
        .match(event.request)
        .then((response) => {
          if (response) {
            // If there is an entry in the cache for event.request,
            // then response will be defined and we can just return it.
            // Note that in this example, only font resources are cached.
            console.log(" Found response in cache:", response);

            return response;
          }

          // Otherwise, if there is no entry in the cache for event.request,
          // response will be undefined, and we need to fetch() the resource.
          console.log(
            " No response for %s found in cache. About to fetch " +
              "from network…",
            event.request.url,
          );

          // We call .clone() on the request since we might use it
          // in a call to cache.put() later on.
          // Both fetch() and cache.put() "consume" the request,
          // so we need to make a copy.
          // (see https://developer.mozilla.org/en-US/docs/Web/API/Request/clone)
          return fetch(event.request.clone()).then((response) => {
            console.log(
              " Response for %s from network is: %O",
              event.request.url,
              response,
            );

            if (
              response.status < 400 &&
              response.headers.has("content-type") &&
              response.headers.get("content-type").match(/^font\//i)
            ) {
              // This avoids caching responses that we know are errors
              // (i.e. HTTP status code of 4xx or 5xx).
              // We also only want to cache responses that correspond
              // to fonts, i.e. have a Content-Type response header that
              // starts with "font/".
              // Note that for opaque filtered responses
              // https://fetch.spec.whatwg.org/#concept-filtered-response-opaque
              // we can't access to the response headers, so this check will
              // always fail and the font won't be cached.
              // All of the Google Web Fonts are served from a domain that
              // supports CORS, so that isn't an issue here.
              // It is something to keep in mind if you're attempting
              // to cache other resources from a cross-origin
              // domain that doesn't support CORS, though!
              console.log(" Caching the response to", event.request.url);
              // We call .clone() on the response to save a copy of it
              // to the cache. By doing so, we get to keep the original
              // response object which we will return back to the controlled
              // page.
              // https://developer.mozilla.org/en-US/docs/Web/API/Request/clone
              cache.put(event.request, response.clone());
            } else {
              console.log(" Not caching the response to", event.request.url);
            }

            // Return the original response object, which will be used to
            // fulfill the resource request.
            return response;
          });
        })
        .catch((error) => {
          // This catch() will handle exceptions that arise from the match()
          // or fetch() operations.
          // Note that a HTTP error response (e.g. 404) will NOT trigger
          // an exception.
          // It will return a normal response object that has the appropriate
          // error code set.
          console.error(" Error in fetch handler:", error);

          throw error;
        });
    }),
  );
});
```

### Cookies and Cache objects

The Fetch API requires `Set-Cookie` headers to be stripped before returning a `Response` object from `fetch()`. So a `Response` stored in a `Cache` won't contain `Set-Cookie` headers, and therefore won't cause any cookies to be stored.

Specifications
--------------

| Specification |
| --- |
| Service Workers # cache-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using Service Workers
* Service workers basic code example
* Using web workers


WebGLShaderPrecisionFormat - Web APIs

WebGLShaderPrecisionFormat
==========================

The **WebGLShaderPrecisionFormat** interface is part of the WebGL API and represents the information returned by calling the `WebGLRenderingContext.getShaderPrecisionFormat()` method.

Instance properties
-------------------

`WebGLShaderPrecisionFormat.rangeMin` Read only

The base 2 log of the absolute value of the minimum value that can be represented.

`WebGLShaderPrecisionFormat.rangeMax` Read only

The base 2 log of the absolute value of the maximum value that can be represented.

`WebGLShaderPrecisionFormat.precision` Read only

The number of bits of precision that can be represented. For integer formats this value is always 0.

Examples
--------

A `WebGLShaderPrecisionFormat` object is returned by the `WebGLRenderingContext.getShaderPrecisionFormat()` method.

```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.getShaderPrecisionFormat(gl.VERTEX\_SHADER, gl.MEDIUM\_FLOAT);
// WebGLShaderPrecisionFormat { rangeMin: 127, rangeMax: 127, precision: 23 }
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.12 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.getShaderPrecisionFormat()`


ServiceWorkerGlobalScope - Web APIs

ServiceWorkerGlobalScope
========================

The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker.

Developers should keep in mind that the ServiceWorker state is not persisted across the termination/restart cycle, so each event handler should assume it's being invoked with a bare, default global state.

Once successfully registered, a service worker can and will be terminated when idle to conserve memory and processor power. An active service worker is automatically restarted to respond to events, such as `fetch` or `message`.

Additionally, synchronous requests are not allowed from within a service worker — only asynchronous requests, like those initiated via the `fetch()` method, can be used.

This interface inherits from the `WorkerGlobalScope` interface, and its parent `EventTarget`.

EventTarget

WorkerGlobalScope

ServiceWorkerGlobalScopeInstance properties
-------------------

*This interface inherits properties from the `WorkerGlobalScope` interface, and its parent `EventTarget`.*

`ServiceWorkerGlobalScope.clients` Read only

Contains the `Clients` object associated with the service worker.

`ServiceWorkerGlobalScope.cookieStore` Read only
Experimental

Returns a reference to the `CookieStore` object associated with the service worker.

`ServiceWorkerGlobalScope.registration` Read only

Contains the `ServiceWorkerRegistration` object that represents the service worker's registration.

`ServiceWorkerGlobalScope.serviceWorker` Read only

Contains the `ServiceWorker` object that represents the service worker.

Instance methods
----------------

*This interface inherits methods from the `WorkerGlobalScope` interface, and its parent `EventTarget`.*

`ServiceWorkerGlobalScope.skipWaiting()`

Allows the current service worker registration to progress from waiting to active state while service worker clients are using it.

Events
------

Listen to this event using `addEventListener()` or by assigning an event listener to the `oneventname` property of this interface.

`activate`

Occurs when a `ServiceWorkerRegistration` acquires a new `ServiceWorkerRegistration.active` worker.

`backgroundfetchabort`
Experimental

Fired when a background fetch operation has been canceled by the user or the app.

`backgroundfetchclick`
Experimental

Fired when the user has clicked on the UI for a background fetch operation.

`backgroundfetchfail`
Experimental

Fired when at least one of the requests in a background fetch operation has failed.

`backgroundfetchsuccess`
Experimental

Fired when all of the requests in a background fetch operation have succeeded.

`canmakepayment`
Experimental

Fired on a payment app's service worker to check whether it is ready to handle a payment. Specifically, it is fired when the merchant website calls `new PaymentRequest()`.

`contentdelete`
Experimental

Occurs when an item is removed from the `Content Index`.

`cookiechange`
Experimental

Fired when a cookie change has occurred that matches the service worker's cookie change subscription list.

`fetch`

Occurs when a `fetch()` is called.

`install`

Occurs when a `ServiceWorkerRegistration` acquires a new `ServiceWorkerRegistration.installing` worker.

`message`

Occurs when incoming messages are received. Controlled pages can use the `MessagePort.postMessage()` method to send messages to service workers.

`messageerror`

Occurs when incoming messages can't be deserialized.

`notificationclick`

Occurs when a user clicks on a displayed notification.

`notificationclose`

Occurs when a user closes a displayed notification.

`paymentrequest`
Experimental

Fired on a payment app when a payment flow has been initiated on the merchant website via the `PaymentRequest.show()` method.

`sync`

Triggered when a call to `SyncManager.register` is made from a service worker client page. The attempt to sync is made either immediately if the network is available or as soon as the network becomes available.

`periodicsync`
Experimental

Occurs at periodic intervals, which were specified when registering a `PeriodicSyncManager`.

`push`

Occurs when a server push notification is received.

`pushsubscriptionchange`

Occurs when a push subscription has been invalidated, or is about to be invalidated (e.g. when a push service sets an expiration time).

Examples
--------

This code snippet is from the service worker prefetch sample (see prefetch example live.) The `onfetch` event handler listens for the `fetch` event. When fired, the code returns a promise that resolves to the first matching request in the `Cache` object. If no match is found, the code fetches a response from the network.

The code also handles exceptions thrown from the `fetch()` operation. Note that an HTTP error response (e.g., 404) will not trigger an exception. It will return a normal response object that has the appropriate error code set.

```js
self.addEventListener("fetch", (event) => {
  console.log("Handling fetch event for", event.request.url);

  event.respondWith(
    caches.match(event.request).then((response) => {
      if (response) {
        console.log("Found response in cache:", response);

        return response;
      }
      console.log("No response found in cache. About to fetch from network…");

      return fetch(event.request).then(
        (response) => {
          console.log("Response from network is:", response);

          return response;
        },
        (error) => {
          console.error("Fetching failed:", error);

          throw error;
        },
      );
    }),
  );
});
```

Specifications
--------------

| Specification |
| --- |
| Service Workers # serviceworkerglobalscope-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using Service Workers
* Service workers basic code example


Scheduler - Web APIs

Scheduler
=========

Limited availability
--------------------

This feature is not Baseline because it does not work in some of the most widely-used browsers.

* Learn more
* See full compatibility
* Report feedback
The **`Scheduler`** interface of the Prioritized Task Scheduling API provides the `Scheduler.postTask()` method that can be used for adding prioritized tasks to be scheduled.

A `Scheduler` can be accessed from the global object `Window` or `WorkerGlobalScope` (`this.scheduler`).

Instance properties
-------------------

None.

Instance methods
----------------

`Scheduler.postTask()`

Adds a task to the scheduler as a callback, optionally specifying a priority, delay, and/or a signal for aborting the task.

Examples
--------

 If the feature is defined, an instance of this object is returned by the global `this` in both workers and the main thread.
 The only property of the interface is the `postTask()` method, which is used to post the task and returns a promise.

 The code below shows a simple task that resolves with the text 'Task executing'.
 This text is logged on success.
 The code also shows a `catch` block, which would be required in more complex code to handle when a task is aborted or throws an error.

```js
if ("scheduler" in this) {
  // Post task with default priority: 'user-visible' (no other options)
  // When the task resolves, Promise.then() logs the result.
  scheduler
    .postTask(() => "Task executing")
    .then((taskResult) => console.log(`${taskResult}`)) // Log result
    .catch((error) => console.error(`Error: ${error}`)); // Log errors
}
```

For more comprehensive example code see Prioritized Task Scheduling API > Examples.

Specifications
--------------

| Specification |
| --- |
| Prioritized Task Scheduling # scheduler |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


Node - Web APIs

Node
====

 The DOM **`Node`** interface is an abstract base
 class upon which many other DOM API objects are based, thus letting those object types
 to be used similarly and often interchangeably. As an abstract class, there is
 no such thing as a plain `Node` object. All objects that implement
 `Node` functionality are based on one of its subclasses. Most notable are
 `Document`, `Element`, and `DocumentFragment`.

 In addition, every kind of DOM node is represented by an interface based on
 `Node`. These include `Attr`, `CharacterData`
 (which `Text`, `Comment`, `CDATASection` and
 `ProcessingInstruction` are all based on), and `DocumentType`.

 In some cases, a particular feature of the base `Node` interface may not
 apply to one of its child interfaces; in that case, the inheriting node may
 return `null` or throw an exception, depending on circumstances. For example,
 attempting to add children to a node type that cannot have children will throw an
 exception.

EventTarget

NodeInstance properties
-------------------

*In addition to the properties below, `Node` inherits properties from its parent, `EventTarget`*.

`Node.baseURI` Read only

 Returns a string representing the base URL of the document
 containing the `Node`.

`Node.childNodes` Read only

 Returns a live `NodeList` containing all the children of this node
 (including elements, text and comments). `NodeList` being live means that
 if the children of the `Node` change, the `NodeList` object is
 automatically updated.

`Node.firstChild` Read only

 Returns a `Node` representing the first direct child node of the node,
 or `null` if the node has no child.

`Node.isConnected` Read only

 A boolean indicating whether or not the Node is connected (directly or indirectly)
 to the context object, e.g. the `Document` object in the case of the
 normal DOM, or the `ShadowRoot` in the case of a shadow DOM.

`Node.lastChild` Read only

 Returns a `Node` representing the last direct child node of the node,
 or `null` if the node has no child.

`Node.nextSibling` Read only

 Returns a `Node` representing the next node in the tree, or
 `null` if there isn't such node.

`Node.nodeName` Read only

 Returns a string containing the name of the `Node`. The
 structure of the name will differ with the node type. E.g. An
 `HTMLElement` will contain the name of the corresponding tag, like
 `'audio'` for an `HTMLAudioElement`, a `Text`
 node will have the `'#text'` string, or a `Document` node will
 have the `'#document'` string.

`Node.nodeType` Read only

 Returns an `unsigned short` representing the type of the node. Possible
 values are:

| Name | Value |
| --- | --- |
| `ELEMENT_NODE` | `1` |
| `ATTRIBUTE_NODE` | `2` |
| `TEXT_NODE` | `3` |
| `CDATA_SECTION_NODE` | `4` |
| `PROCESSING_INSTRUCTION_NODE` | `7` |
| `COMMENT_NODE` | `8` |
| `DOCUMENT_NODE` | `9` |
| `DOCUMENT_TYPE_NODE` | `10` |
| `DOCUMENT_FRAGMENT_NODE` | `11` |

`Node.nodeValue`

Returns / Sets the value of the current node.

`Node.ownerDocument` Read only

 Returns the `Document` that this node belongs to. If the node is itself
 a document, returns `null`.

`Node.parentNode` Read only

 Returns a `Node` that is the parent of this node. If there is no such
 node, like if this node is the top of the tree or if doesn't participate in a tree,
 this property returns `null`.

`Node.parentElement` Read only

 Returns an `Element` that is the parent of this node. If the node has
 no parent, or if that parent is not an `Element`, this property returns
 `null`.

`Node.previousSibling` Read only

 Returns a `Node` representing the previous node in the tree, or
 `null` if there isn't such node.

`Node.textContent`

Returns / Sets the textual content of an element and all its descendants.

Instance methods
----------------

*In addition to the methods below, `Node` inherits methods from its parent, `EventTarget`.*

`Node.appendChild()`

 Adds the specified `childNode` argument as the last child to the current node.
 If the argument referenced an existing node on the DOM tree, the node will be detached
 from its current position and attached at the new position.

`Node.cloneNode()`

 Clone a `Node`, and optionally, all of its contents. By default, it
 clones the content of the node.

`Node.compareDocumentPosition()`

Compares the position of the current node against another node in any other document.

`Node.contains()`

 Returns `true` or `false` value indicating whether or not a node is a
 descendant of the calling node.

`Node.getRootNode()`

Returns the context object's root which optionally includes the shadow root if it is available.

`Node.hasChildNodes()`

Returns a boolean value indicating whether or not the element has any child nodes.

`Node.insertBefore()`

 Inserts a `Node` before the reference node as a child of a specified
 parent node.

`Node.isDefaultNamespace()`

 Accepts a namespace URI as an argument and returns a boolean value with a
 value of `true` if the namespace is the default namespace on the given node
 or `false` if not.

`Node.isEqualNode()`

 Returns a boolean value which indicates whether or not two nodes are of the
 same type and all their defining data points match.

`Node.isSameNode()`

 Returns a boolean value indicating whether or not the two nodes are
 the same (that is, they reference the same object).

`Node.lookupPrefix()`

 Returns a string containing the prefix for a given namespace URI,
 if present, and `null` if not. When multiple prefixes are possible, the
 result is implementation-dependent.

`Node.lookupNamespaceURI()`

 Accepts a prefix and returns the namespace URI associated with it on the given node
 if found (and `null` if not). Supplying `null` for the prefix
 will return the default namespace.

`Node.normalize()`

Clean up all the text nodes under this element (merge adjacent, remove empty).

`Node.removeChild()`

 Removes a child node from the current element, which must be a child of the current
 node.

`Node.replaceChild()`

 Replaces one child `Node` of the current one with the second one given
 in parameter.

Examples
--------

### Remove all children nested within a node

This function remove each first child of an element, until there are none left.

```js
function removeAllChildren(element) {
  while (element.firstChild) {
    element.removeChild(element.firstChild);
  }
}
```

Using this function is a single call. Here we empty the body of the document:

```js
removeAllChildren(document.body);
```

An alternative could be to set the textContent to the empty string: `document.body.textContent = ""`.

### Recurse through child nodes

 The following function recursively calls a callback function for each node contained by
 a root node (including the root itself):

```js
function eachNode(rootNode, callback) {
  if (!callback) {
    const nodes = [];
    eachNode(rootNode, (node) => {
      nodes.push(node);
    });
    return nodes;
  }

  if (callback(rootNode) === false) {
    return false;
  }

  if (rootNode.hasChildNodes()) {
    for (const node of rootNode.childNodes) {
      if (eachNode(node, callback) === false) {
        return;
      }
    }
  }
}
```

 The function recursively calls a function for each descendant node of
 `rootNode` (including the root itself).

 If `callback` is omitted, the function returns an
 `Array` instead, which contains `rootNode` and all
 nodes contained within.

 If `callback` is provided, and it returns
 `false` when called, the current recursion level is aborted, and the function
 resumes execution at the last parent's level. This can be used to abort loops once a
 node has been found (such as searching for a text node which contains a certain string).

The function has two parameters:

`rootNode`

The `Node` object whose descendants will be recursed through.

`callback` Optional

 An optional callback function that
 receives a `Node` as its only argument. If omitted, `eachNode`
 returns an `Array` of every node contained within
 `rootNode` (including the root itself).

 The following demonstrates a real-world use of the `eachNode()` function:
 searching for text on a web-page.

We use a wrapper function named `grep` to do the searching:

```js
function grep(parentNode, pattern) {
  let matches = [];
  let endScan = false;

  eachNode(parentNode, (node) => {
    if (endScan) {
      return false;
    }

    // Ignore anything which isn't a text node
    if (node.nodeType !== Node.TEXT\_NODE) {
      return;
    }

    if (typeof pattern === "string" && node.textContent.includes(pattern)) {
      matches.push(node);
    } else if (pattern.test(node.textContent)) {
      if (!pattern.global) {
        endScan = true;
        matches = node;
      } else {
        matches.push(node);
      }
    }
  });

  return matches;
}
```

Specifications
--------------

| Specification |
| --- |
| DOM Standard # interface-node |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


File and Directory Entries API - Web APIs

File and Directory Entries API
==============================

The File and Directory Entries API simulates a local file system that web apps can navigate within and access files in. You can develop apps which read, write, and create files and/or directories in a virtual, sandboxed file system.

Getting access to a file system
-------------------------------

There are two ways to get access to file systems defined in the current specification draft:

* When handling a `drop` event for drag and drop, you can call `DataTransferItem.webkitGetAsEntry()` to get the `FileSystemEntry` for a dropped item. If the result isn't `null`, then it's a dropped file or directory, and you can use file system calls to work with it.
* The `HTMLInputElement.webkitEntries` property lets you access the `FileSystemFileEntry` objects for the currently selected files, but only if they are dragged-and-dropped onto the file chooser (Firefox bug 1326031). If `HTMLInputElement.webkitdirectory` is `true`, the `<input>` element is instead a directory picker, and you get `FileSystemDirectoryEntry` objects for each selected directory.
Interfaces
----------

The File and Directory Entries API includes the following interfaces:

`FileSystem`

Represents a file system.

`FileSystemEntry`

The basic interface representing a single entry in a file system. This is implemented by other interfaces which represent files or directories.

`FileSystemFileEntry`

Represents a single file in a file system.

`FileSystemDirectoryEntry`

Represents a single directory in a file system.

`FileSystemDirectoryReader`

Created by calling `FileSystemDirectoryEntry.createReader()`, this interface provides the functionality which lets you read the contents of a directory.

Specifications
--------------

| Specification |
| --- |
| File and Directory Entries API # api-domfilesystem |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Introduction to the File and Directory Entries API
* File and Directory Entries API support in Firefox


AudioScheduledSourceNode - Web APIs

AudioScheduledSourceNode
========================

The `AudioScheduledSourceNode` interface—part of the Web Audio API—is a parent interface for several types of audio source node interfaces which share the ability to be started and stopped, optionally at specified times. Specifically, this interface defines the `start()` and `stop()` methods, as well as the `ended` event.

**Note:** You can't create an `AudioScheduledSourceNode` object directly. Instead, use an interface which extends it, such as `AudioBufferSourceNode`, `OscillatorNode` or `ConstantSourceNode`.

Unless stated otherwise, nodes based upon `AudioScheduledSourceNode` output silence when not playing (that is, before `start()` is called and after `stop()` is called). Silence is represented, as always, by a stream of samples with the value zero (0).

EventTarget

AudioNode

AudioScheduledSourceNodeInstance properties
-------------------

*Inherits properties from its parent interface, `AudioNode`.*

Instance methods
----------------

*Inherits methods from its parent interface, `AudioNode`, and adds the following methods:*

`start()`

Schedules the node to begin playing the constant sound at the specified time. If no time is specified, the node begins playing immediately.

`stop()`

Schedules the node to stop playing at the specified time. If no time is specified, the node stops playing at once.

Events
------

Listen to these events using `addEventListener()` or by assigning an event listener to the `oneventname` property of this interface:

`ended`

Fired when the source node has stopped playing, either because it's reached a predetermined stop time, the full duration of the audio has been performed, or because the entire buffer has been played.

Specifications
--------------

| Specification |
| --- |
| Web Audio API # AudioScheduledSourceNode |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using the Web Audio API
* `AudioNode`


RTCRtpSender - Web APIs

RTCRtpSender
============

The **`RTCRtpSender`** interface provides the ability to control and obtain details about how a particular `MediaStreamTrack` is encoded and sent to a remote peer.

With it, you can configure the encoding used for the corresponding track, get information about the device's media capabilities, and so forth. You can also obtain access to an `RTCDTMFSender` which can be used to send DTMF codes (to simulate the user pressing buttons on a telephone's dial pad) to the remote peer.

Instance properties
-------------------

`RTCRtpSender.dtmf` Read only

An `RTCDTMFSender` which can be used to send DTMF tones using `telephone-event` payloads on the RTP session represented by the `RTCRtpSender` object. If `null`, the track and/or the connection doesn't support DTMF. Only audio tracks can support DTMF.

`RTCRtpSender.track` Read only

The `MediaStreamTrack` which is being handled by the `RTCRtpSender`. If `track` is `null`, the `RTCRtpSender` doesn't transmit anything.

`RTCRtpSender.transport` Read only

The `RTCDtlsTransport` over which the sender is exchanging the RTP and RTCP packets used to manage transmission of media and control data. This value is `null` until the transport is established. When bundling is in use, more than transceiver may be sharing the same transport object.

`RTCRtpSender.transform`

An `RTCRtpScriptTransform` is used to insert a transform stream (`TransformStream`) running in a worker thread into the sender pipeline, allowing stream transforms to be applied to encoded video and audio frames after they are output by a codec, and before they are sent.

### Obsolete properties

`rtcpTransport`
Deprecated

This property has been removed; the RTP and RTCP transports have been combined into a single transport. Use the `transport` property instead.

Static methods
--------------

`RTCRtpSender.getCapabilities()`

Returns an object describing the system's capabilities for sending a specified kind of media data.

Instance methods
----------------

`RTCRtpSender.getParameters()`

Returns an object describing the current configuration for the encoding and transmission of media on the `track`.

`RTCRtpSender.getStats()`

Returns a `Promise` which is fulfilled with a `RTCStatsReport` which provides statistics data for all outbound streams being sent using this `RTCRtpSender`.

`RTCRtpSender.setParameters()`

Applies changes to parameters which configure how the `track` is encoded and transmitted to the remote peer.

`RTCRtpSender.setStreams()`

Sets the `MediaStream`(s) associated with the `track` being transmitted by this sender.

`RTCRtpSender.replaceTrack()`

Attempts to replace the track currently being sent by the `RTCRtpSender` with another track, without performing renegotiation. This method can be used, for example, to toggle between the front- and rear-facing cameras on a device.

Specifications
--------------

| Specification |
| --- |
| WebRTC: Real-Time Communication in Browsers # rtcrtpsender-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* WebRTC API
* `RTCPeerConnection.addTrack()`
* `RTCPeerConnection.getSenders()`
* `RTCRtpReceiver`


ScreenOrientation - Web APIs

ScreenOrientation
=================

The **`ScreenOrientation`** interface of the Screen Orientation API provides information about the current orientation of the document.

A **`ScreenOrientation`** instance object can be retrieved using the `screen.orientation` property.

EventTarget

ScreenOrientationInstance properties
-------------------

`ScreenOrientation.type` Read only

Returns the document's current orientation type, one of `portrait-primary`, `portrait-secondary`, `landscape-primary`, or `landscape-secondary`.

`ScreenOrientation.angle` Read only

Returns the document's current orientation angle.

Instance methods
----------------

`ScreenOrientation.lock()`

Locks the orientation of the containing document to its default orientation and returns a `Promise`.

`ScreenOrientation.unlock()`

Unlocks the orientation of the containing document from its default orientation.

Events
------

Listen to these events using `addEventListener()` or by assigning an event listener to the `oneventname` property of this interface.

`change`

Fired whenever the screen changes orientation.

Example
-------

In the following example, we listen for an orientation `change` event and log the new screen orientation type and angle.

```js
screen.orientation.addEventListener("change", (event) => {
  const type = event.target.type;
  const angle = event.target.angle;
  console.log(`ScreenOrientation change: ${type}, ${angle} degrees.`);
});
```

Specifications
--------------

| Specification |
| --- |
| Screen Orientation # screenorientation-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


EventCounts - Web APIs

EventCounts
===========

The **`EventCounts`** interface of the Performance API provides the number of events that have been dispatched for each event type.

An `EventCounts` instance is a read-only `Map`-like object, in which each key is the name string for an event type, and the corresponding value is an integer indicating the number of events that have been dispatched for that event type.

Constructor
-----------

This interface has no constructor. You typically get an instance of this object using the `performance.eventCounts` property.

Instance properties
-------------------

`size`

See `Map.prototype.size` for details.

Instance methods
----------------

`entries()`

See `Map.prototype.entries()` for details.

`forEach()`

See `Map.prototype.forEach()` for details.

`get()`

See `Map.prototype.get()` for details.

`has()`

See `Map.prototype.has()` for details.

`keys()`

See `Map.prototype.keys()` for details.

`values()`

See `Map.prototype.values()` for details.

Examples
--------

### Working with EventCount maps

Below are a few examples to get information from an `EventCounts` map. Note that the map is read-only and the `clear()`, `delete()`, and `set()` methods aren't available.

```js
for (entry of performance.eventCounts.entries()) {
  const type = entry[0];
  const count = entry[1];
}

const clickCount = performance.eventCounts.get("click");

const isExposed = performance.eventCounts.has("mousemove");
const exposedEventsCount = performance.eventCounts.size;
const exposedEventsList = [...performance.eventCounts.keys()];
```

Specifications
--------------

| Specification |
| --- |
| Event Timing API # sec-event-counts |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `performance.eventCounts`
* `PerformanceEventTiming`
* `Map`


WorkerGlobalScope - Web APIs

WorkerGlobalScope
=================

The **`WorkerGlobalScope`** interface of the Web Workers API is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by `Window` objects — in this case event handlers, the console or the associated `WorkerNavigator` object. Each `WorkerGlobalScope` has its own event loop.

This interface is usually specialized by each worker type: `DedicatedWorkerGlobalScope` for dedicated workers, `SharedWorkerGlobalScope` for shared workers, and `ServiceWorkerGlobalScope` for ServiceWorker. The `self` property returns the specialized scope for each context.

EventTarget

WorkerGlobalScopeInstance properties
-------------------

*This interface inherits properties from the `EventTarget` interface.*

### Standard properties

`WorkerGlobalScope.caches` Read only

Returns the `CacheStorage` object associated with the current context. This object enables functionality such as storing assets for offline use, and generating custom responses to requests.

`WorkerGlobalScope.crossOriginIsolated` Read only

Returns a boolean value that indicates whether the website is in a cross-origin isolation state.

`WorkerGlobalScope.crypto` Read only

Returns the `Crypto` object associated to the global object.

`WorkerGlobalScope.fonts` Read only

Returns the `FontFaceSet` associated with the worker.

`WorkerGlobalScope.indexedDB` Read only

Provides a mechanism for applications to asynchronously access capabilities of indexed databases; returns an `IDBFactory` object.

`WorkerGlobalScope.isSecureContext` Read only

Returns a boolean indicating whether the current context is secure (`true`) or not (`false`).

`WorkerGlobalScope.location` Read only

Returns the `WorkerLocation` associated with the worker. It is a specific location object, mostly a subset of the `Location` for browsing scopes, but adapted to workers.r.

`WorkerGlobalScope.navigator` Read only

Returns the `WorkerNavigator` associated with the worker. It is a specific navigator object, mostly a subset of the `Navigator` for browsing scopes, but adapted to workers.

`WorkerGlobalScope.origin` Read only

Returns the global object's origin, serialized as a string.

`WorkerGlobalScope.performance` Read only

Returns the `Performance` associated with the worker. It is a regular performance object, except that only a subset of its property and methods are available to workers.

`WorkerGlobalScope.scheduler` Read only

Returns the `Scheduler` object associated with the current context. This is the entry point for using the Prioritized Task Scheduling API.

`WorkerGlobalScope.self` Read only

Returns a reference to the `WorkerGlobalScope` itself. Most of the time it is a specific scope like `DedicatedWorkerGlobalScope`, `SharedWorkerGlobalScope` or `ServiceWorkerGlobalScope`.

### Non-standard properties

`console` Read only
Non-standard

Returns the `console` associated with the worker.

Instance methods
----------------

*This interface inherits methods from the `EventTarget` interface.*

### Standard methods

`WorkerGlobalScope.atob()`

Decodes a string of data which has been encoded using base-64 encoding.

`WorkerGlobalScope.btoa()`

Creates a base-64 encoded ASCII string from a string of binary data.

`WorkerGlobalScope.clearInterval()`

Cancels the repeated execution set using `setInterval()`.

`WorkerGlobalScope.clearTimeout()`

Cancels the delayed execution set using `setTimeout()`.

`WorkerGlobalScope.createImageBitmap()`

Accepts a variety of different image sources, and returns a `Promise` which resolves to an `ImageBitmap`. Optionally the source is cropped to the rectangle of pixels originating at *(sx, sy)* with width sw, and height sh.

`WorkerGlobalScope.fetch()`

Starts the process of fetching a resource from the network.

`WorkerGlobalScope.importScripts()`

Imports one or more scripts into the worker's scope. You can specify as many as you'd like, separated by commas. For example: `importScripts('foo.js', 'bar.js');`.

`WorkerGlobalScope.queueMicrotask()`

Queues a microtask to be executed at a safe time prior to control returning to the browser's event loop.

`WorkerGlobalScope.setInterval()`

Schedules a function to execute every time a given number of milliseconds elapses.

`WorkerGlobalScope.setTimeout()`

Schedules a function to execute in a given amount of time.

`WorkerGlobalScope.structuredClone()`

Creates a deep clone of a given value using the structured clone algorithm.

`WorkerGlobalScope.reportError()`

Reports an error in a script, emulating an unhandled exception.

### Non-standard methods

`WorkerGlobalScope.dump()`
Deprecated

Non-standard

Allows you to write a message to stdout — i.e. in your terminal. This is the same as Firefox's `window.dump`, but for workers.

Events
------

`error`

Fired when an error occurred.

`languagechange`

Fired at the global/worker scope object when the user's preferred languages change.

`offline`

Fired when the browser has lost access to the network and the value of `navigator.onLine` switched to `false`.

`online`

Fired when the browser has gained access to the network and the value of `navigator.onLine` switched to `true`.

`rejectionhandled`

Fired on handled `Promise` rejection events.

`securitypolicyviolation`

Fired when a Content Security Policy is violated.

`unhandledrejection`

Fired on unhandled `Promise` rejection events.

Example
-------

You won't access `WorkerGlobalScope` directly in your code; however, its properties and methods are inherited by more specific global scopes such as `DedicatedWorkerGlobalScope` and `SharedWorkerGlobalScope`. For example, you could import another script into the worker and print out the contents of the worker scope's `navigator` object using the following two lines:

```js
importScripts("foo.js");
console.log(navigator);
```

**Note:** Since the global scope of the worker script is effectively the global scope of the worker you are running (`DedicatedWorkerGlobalScope` or whatever) and all worker global scopes inherit methods, properties, etc. from `WorkerGlobalScope`, you can run lines such as those above without specifying a parent object.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # the-workerglobalscope-common-interface |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Other global object interface: `Window`, `DedicatedWorkerGlobalScope`, `SharedWorkerGlobalScope`, `ServiceWorkerGlobalScope`
* Other Worker-related interfaces: `Worker`, `WorkerLocation` and `WorkerNavigator`
* Using web workers


TextDecoderStream - Web APIs

TextDecoderStream
=================

 The **`TextDecoderStream`** interface of the Encoding API converts a stream of text in a binary encoding, such as UTF-8 etc., to a stream of strings.
 It is the streaming equivalent of `TextDecoder`.

Constructor
-----------

`TextDecoderStream()`

Creates a new `TextDecoderStream` object.

Instance properties
-------------------

`TextDecoderStream.encoding` Read only

An encoding.

`TextDecoderStream.fatal` Read only

A `boolean` indicating if the error mode is fatal.

`TextDecoderStream.ignoreBOM` Read only

A `boolean` indicating whether the byte order mark is ignored.

`TextDecoderStream.readable` Read only

Returns the `ReadableStream` instance controlled by this object.

`TextDecoderStream.writable` Read only

Returns the `WritableStream` instance controlled by this object.

Examples
--------

* Examples of streaming structured data and HTML
* An example of fetch request streams which uses `TextDecoderStream`.
Specifications
--------------

| Specification |
| --- |
| Encoding Standard # interface-textdecoderstream |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `TextEncoderStream`
* Streams API Concepts
* Experimenting with the Streams API


performance global property - Web APIs

performance global property
===========================

**Note:** This feature is available in Web Workers

The global **`performance`** property returns a `Performance` object, which can be used to gather performance information about the context it is called in (window or worker).

Performance entries are per context. If you create a mark on the main thread (or other worker), you cannot see it in a worker thread, and vice versa.

Value
-----

A `Performance` object offering access to performance and timing-related information for the context it is called on (window or worker).

Performance API availability
----------------------------

The following table provides an overview about the availability of the performance APIs in window and worker contexts.

| API | Window | Worker |
| --- | --- | --- |
| `LargestContentfulPaint` | x |  |
| `LayoutShift` | x |  |
| `LayoutShiftAttribution` | x |  |
| `Performance` | x | x |
| `PerformanceElementTiming` | x |  |
| `PerformanceEntry` | x | x |
| `PerformanceEventTiming` | x |  |
| `PerformanceLongTaskTiming` | x |  |
| `PerformanceMark` | x | x |
| `PerformanceMeasure` | x | x |
| `PerformanceNavigation`
Deprecated
 | x |  |
| `PerformanceNavigationTiming` | x |  |
| `PerformanceObserver` | x | x |
| `PerformanceObserverEntryList` | x | x |
| `PerformancePaintTiming` | x |  |
| `PerformanceResourceTiming` | x | x |
| `PerformanceServerTiming` | x | x |
| `PerformanceTiming`
Deprecated
 | x |  |
| `TaskAttributionTiming` | x |  |
| `VisibilityStateEntry` | x |  |

Specifications
--------------

| Specification |
| --- |
| High Resolution Time # the-performance-attribute |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.


WebGLUniformLocation - Web APIs

WebGLUniformLocation
====================

The **WebGLUniformLocation** interface is part of the WebGL API and represents the location of a uniform variable in a shader program.

Description
-----------

The `WebGLUniformLocation` object does not define any methods or properties of its own and its content is not directly accessible. When working with `WebGLUniformLocation` objects, the following methods of the `WebGLRenderingContext` are useful:

* `WebGLRenderingContext.getUniformLocation()`
* `WebGLRenderingContext.uniform()`
Examples
--------

### Getting an uniform location

```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");

const location = gl.getUniformLocation(WebGLProgram, "uniformName");
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.10 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.getUniformLocation()`


HTMLTableColElement - Web APIs

HTMLTableColElement
===================

The **`HTMLTableColElement`** interface provides properties for manipulating single or grouped table column elements.

EventTarget

Node

Element

HTMLElement

HTMLTableColElementInstance properties
-------------------

*Inherits properties from its parent, `HTMLElement`*.

`HTMLTableColElement.align`
Deprecated

A string that indicates the horizontal alignment of the cell data in the column.

`HTMLTableColElement.ch`
Deprecated

A string representing the alignment character for cell data.

`HTMLTableColElement.chOff`
Deprecated

A string representing the offset for the alignment character.

`HTMLTableColElement.span`

An `unsigned long` that reflects the `span` HTML attribute, indicating the number of columns to apply this object's attributes to. Must be a positive integer.

`HTMLTableColElement.vAlign`
Deprecated

A string that indicates the vertical alignment of the cell data in the column.

`HTMLTableColElement.width`
Deprecated

A string representing the default column width.

Instance methods
----------------

*No specific method; inherits methods from its parent, `HTMLElement`*.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # htmltablecolelement |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* The HTML element implementing this interface: `<col>` and `<colgroup>`.


crossOriginIsolated global property - Web APIs

crossOriginIsolated global property
===================================

**Note:** This feature is available in Web Workers

 The global **`crossOriginIsolated`** read-only property returns a boolean value that
 indicates whether the website is in a cross-origin isolation state. That state mitigates the risk of side-channel attacks and unlocks a few capabilities:

* `SharedArrayBuffer` can be created and sent via a `Window.postMessage()` call.
* `Performance.now()` offers better precision.
* `Performance.measureUserAgentSpecificMemory()` can be accessed.

A website is in a cross-origin isolated state, when the response header `Cross-Origin-Opener-Policy` has the value `same-origin` and the `Cross-Origin-Embedder-Policy` header has the value `require-corp` or `credentialless`.

Value
-----

A boolean value.

Examples
--------

```js
const myWorker = new Worker("worker.js");

if (crossOriginIsolated) {
  const buffer = new SharedArrayBuffer(16);
  myWorker.postMessage(buffer);
} else {
  const buffer = new ArrayBuffer(16);
  myWorker.postMessage(buffer);
}
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-crossoriginisolated-dev |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Service Workers
* Web Workers


HTMLMeterElement - Web APIs

HTMLMeterElement
================

The HTML `<meter>` elements expose the **`HTMLMeterElement`** interface, which provides special properties and methods (beyond the `HTMLElement` object interface they also have available to them by inheritance) for manipulating the layout and presentation of `<meter>` elements.

EventTarget

Node

Element

HTMLElement

HTMLMeterElementInstance properties
-------------------

*Also inherits properties from its parent, `HTMLElement`.*

`HTMLMeterElement.high`

A `double` representing the value of the high boundary, reflecting the `high` attribute.

`HTMLMeterElement.low`

A `double` representing the value of the low boundary, reflecting the `low`attribute.

`HTMLMeterElement.max`

A `double` representing the maximum value, reflecting the `max` attribute.

`HTMLMeterElement.min`

A `double` representing the minimum value, reflecting the `min` attribute.

`HTMLMeterElement.optimum`

A `double` representing the optimum, reflecting the `optimum` attribute.

`HTMLMeterElement.value`

A `double` representing the current value, reflecting the `value` attribute.

`HTMLMeterElement.labels` Read only

A `NodeList` of `<label>` elements that are associated with the element.

Instance methods
----------------

*This interface does not implement any specific methods but inherits methods from its parent, `HTMLElement`.*

Specifications
--------------

| Specification |
| --- |
| HTML Standard # htmlmeterelement |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* The HTML element implementing this interface: `<meter>`