recursal/MDN huggingface dataset:
HTMLScriptElement: supports() static method
===========================================

The **`supports()`** static method of the `HTMLScriptElement` interface provides a simple and consistent method to feature-detect what types of scripts are supported by the user agent.

The method is expected to return `true` for classic and module scripts, which are supported by most modern browsers.

Syntax
------


```js
HTMLScriptElement.supports(type)
```

### Parameters

`type`

 A string literal that indicates the type of script for which support is to be checked.
 Supported values are case sensitive, and include:


`"classic"`

 Test if *classic scripts* are supported.
 "Classic" scripts are the normal/traditional JavaScript files that predate module scripts.


`"module"`

Test if module scripts are supported.

`"importmap"`

Test if import maps are supported.

`"speculationrules"`

Test if speculation rules are supported and enabled.

Any other value will cause the method to return `false`.

### Return value

Returns `true` if the indicated script type is supported and `false` otherwise.

Examples
--------

The code below shows how to check if `HTMLScriptElement.supports()` is defined, and if so, to use it to test whether particular types of scripts are supported.


```js
const log = document.getElementById("log");

function checkSupport(type) {
  const result = HTMLScriptElement.supports(type) ? "true" : "false";
  log.textContent += `HTMLScriptElement.supports('${type}') is ${result}\n`;
}

if (typeof HTMLScriptElement.supports === "undefined") {
  log.textContent = "HTMLScriptElement.supports() method is not supported";
} else {
  // Check if various script types are supported
  checkSupport("module");
  checkSupport("classic");
  checkSupport("importmap");
  checkSupport("speculationrules");
  // Any other value will cause the method to return false
  checkSupport("anything else");
}
```


```
<textarea id="log" rows="6" cols="80"></textarea>
```

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

| Specification |
| --- |
| HTML Standard # dom-script-supports |

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

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

See also
--------

* `HTMLScriptElement`
* `<script>`
* JavaScript modules
* `Worker` constructor
XRRenderState: layers property
==============================

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

The read-only **`layers`** property of the `XRRenderState` interface is an ordered array containing `XRLayer` objects that are displayed by the XR compositor.

Value
-----

An ordered array containing `XRLayer` objects. The order of the layers is "back-to-front".

Examples
--------

### Getting render state layers

 To read the WebXR layers array, use the `layers` property on `XRRenderState`.
 Layers can be set using the `XRSession.updateRenderState()` method.


```js
const xrSession = navigator.xr.requestSession("immersive-ar", {
  optionalFeatures: ["layers"],
});

function onXRSessionStarted(xrSession) {
  const glCanvas = document.createElement("canvas");
  const gl = glCanvas.getContext("webgl", { xrCompatible: true });
  const xrGlBinding = new XRWebGLBinding(xrSession, gl);
  const projectionLayer = new XRWebGLLayer(xrSession, gl);
  const quadLayer = xrGlBinding.createQuadLayer({
    pixelWidth: 1024,
    pixelHeight: 1024,
  });

  xrSession.updateRenderState({
    layers: [projectionLayer, quadLayer],
  });

  xrSession.renderState.layers; // [projectionLayer, quadLayer]
}
```

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

| Specification |
| --- |
| WebXR Layers API Level 1 # dom-xrrenderstate-layers |

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

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

See also
--------

* `XRSession.updateRenderState()`
XRRenderState: inlineVerticalFieldOfView property
=================================================

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

 The read-only **`inlineVerticalFieldOfView`**
 property of the `XRRenderState` interface returns the default vertical
 field of view for `"inline"` sessions and `null` for all immersive
 sessions.

Value
-----

 A `Number` for `"inline"` sessions, which represents the default
 field of view, and `null` for immersive sessions.

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

| Specification |
| --- |
| WebXR Device API # dom-xrrenderstate-inlineverticalfieldofview |

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

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

See also
--------

* `navigator.xr.requestSession()`
* `navigator.xr.isSessionSupported()`
XRRenderState: baseLayer property
=================================

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

 The read-only **`baseLayer`** property of the
 `XRRenderState` interface returns the `XRWebGLLayer` instance
 that is the source of bitmap images and a description of how the image is to be rendered
 in the device.

 This property is read-only; however, you can indirectly change its
 value using `XRSession.updateRenderState`.

Value
-----

 A `XRWebGLLayer` object which is used as the source of the world's
 contents when rendering each frame of the scene.

 See the examples below to see how to use `updateRenderState()` to set the current `XRWebGLLayer` used for rendering
 the scene.

Examples
--------

 You can set the `XRWebGLLayer` used for rendering by calling
 `updateRenderState()`, like this:


```js
let canvas = document.querySelector("canvas");
gl = canvas.getContext("webgl", { xrCompatible: true });
setNewWebGLLayer();

function setNewWebGLLayer(gl) {
  if (!gl) {
    /\* WebGL not available \*/
    return;
  }

  xrSession.updateRenderState({
    baseLayer: new XRWebGLLayer(xrSession, gl),
  });
}
```


 Here, the canvas obtained in the first line is the canvas into which WebGL is going to
 draw. That context is passed into `new
 XRWebGLLayer()` to create an `XRWebGLLayer` which uses the contents of the
 WebGL context `gl` as the source of the world's image during presentation.

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

| Specification |
| --- |
| WebXR Device API # dom-xrrenderstate-baselayer |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
XRRenderState: depthNear property
=================================

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

 The **`depthNear`** read-only property of the
 `XRRenderState` interface returns the distance in meters of the near clip
 plane from the viewer.

Value
-----

A `Number`.

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

| Specification |
| --- |
| WebXR Device API # dom-xrrenderstate-depthnear |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
XRRenderState: depthFar property
================================

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

 The **`depthFar`** read-only property of the
 `XRRenderState` interface returns the distance in meters of the far clip
 plane from the viewer.

Value
-----

A `Number`.

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

| Specification |
| --- |
| WebXR Device API # dom-xrrenderstate-depthfar |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
IdleDeadline: didTimeout property
=================================

 The read-only **`didTimeout`** property on the
 **`IdleDeadline`** interface is a Boolean value which
 indicates whether or not the idle callback is being invoked because the timeout interval
 specified when `Window.requestIdleCallback()` was called has expired.

 If `didTimeout` is `true`, the `IdleDeadline` object's
 `timeRemaining()` method will return
 approximately 0.

 Idle callbacks support the concept of a timeout in order to ensure that whatever task
 they're meant to perform actually happens, even if the user agent never has enough idle
 time available. Your callback will typically check the value of `didTimeout`
 if it needs to perform an action even if the browser is too busy to grant you the time;
 you should react by performing the needed task or, ideally, a minimal amount of work
 that can be done to keep things moving along, then schedule a new callback to try again
 to get the rest of the work done.

Value
-----

 A Boolean which is `true` if the callback is running due to the callback's
 timeout period elapsing or `false` if the callback is running because the
 user agent is idle and is offering time to the callback.

Examples
--------

 See our complete example
 in the article Cooperative Scheduling of Background Tasks API.

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

| Specification |
| --- |
| requestIdleCallback() Cooperative Scheduling of Background Tasks # dom-idledeadline-didtimeout |

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

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

See also
--------

* Collaborative Scheduling of Background Tasks
* `IdleDeadline`
* `Window.requestIdleCallback()`
* `Window.cancelIdleCallback()`
IdleDeadline: timeRemaining() method
====================================

 The **`timeRemaining()`** method
 on the `IdleDeadline` interface returns the estimated number of
 milliseconds remaining in the current idle period. The callback can call this method at
 any time to determine how much time it can continue to work before it must return. For
 example, if the callback finishes a task and has another one to begin, it can call
 `timeRemaining()` to see if there's enough time to complete the next task. If
 there isn't, the callback can just return immediately, or look for other work to do with
 the remaining time.

 By the time `timeRemaining()` reaches 0, it is suggested that the callback
 should return control to the user agent's event loop.

Syntax
------


```js
timeRemaining()
```

### Parameters

None.

### Return value

 A `DOMHighResTimeStamp` value (which is a floating-point number)
 representing the number of milliseconds the user agent estimates are left in the current
 idle period. The value is ideally accurate to within about 5 microseconds.

If the `IdleDeadline` object's `didTimeout` property is true, this method returns zero.

Examples
--------

 See our complete example
 in the article Cooperative Scheduling of Background Tasks API.

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

| Specification |
| --- |
| requestIdleCallback() Cooperative Scheduling of Background Tasks # dom-idledeadline-timeremaining |

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

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

See also
--------

* Collaborative Scheduling of Background Tasks
* `IdleDeadline`
* `Window.requestIdleCallback()`
* `Window.cancelIdleCallback()`
History: forward() method
=========================

 The **`forward()`** method of the `History` interface causes the browser to move
 forward one page in the session history. It has the same effect as calling
 `history.go(1)`.

This method is asynchronous. Add a listener for the `popstate` event in order to determine when the navigation has completed.

Syntax
------


```js
forward()
```

### Parameters

None.

### Return value

None (`undefined`).

### Exceptions

`SecurityError` `DOMException`

Thrown if the associated document is not fully active.

Examples
--------

 The following examples create a button that moves forward one step in the session
 history.

### HTML


```html
<button id="go-forward">Go Forward!</button>
```

### JavaScript


```js
document.getElementById("go-forward").addEventListener("click", (e) => {
  history.forward();
});
```

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

| Specification |
| --- |
| HTML Standard # dom-history-forward-dev |

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

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

See also
--------

* `History`
* `popstate`
* Working with the History API
History: state property
=======================

 The **`state`** read-only property of the `History` interface
 returns a value representing the state at the top of the history stack. This is
 a way to look at the state without having to wait for a `popstate` event.

Value
-----

 The state at the top of the history stack. The value is `null` until the
 `pushState()` or
 `replaceState()` method is used.

Examples
--------

 The code below logs the value of `history.state` before using the
 `pushState()` method to push a value to the history.
 The next line logs the value to the console again, showing that
 `history.state` now has a value.


```js
// Should be null because we haven't modified the history stack yet
console.log("History.state before pushState: ", history.state);

// Now push something on the stack
history.pushState({ name: "Example" }, "pushState example", "page3.html");

// Now state has a value.
console.log("History.state after pushState: ", history.state);
```

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

| Specification |
| --- |
| HTML Standard # dom-history-state-dev |

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

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

See also
--------

* Working with the History API
* `History.pushState()`
* `History.replaceState()`
* `PopStateEvent.state`
History: scrollRestoration property
===================================

 The **`scrollRestoration`** property of the `History`
 interface allows web applications to explicitly set default scroll restoration behavior
 on history navigation.

Value
-----

One of the following:

`auto`

The location on the page to which the user has scrolled will be restored.

`manual`

 The location on the page is not restored. The user will have to scroll to the
 location manually.


Examples
--------

### Query the current scroll restoration behavior


```js
const scrollRestoration = history.scrollRestoration;
if (scrollRestoration === "manual") {
  console.log(
    "The location on the page is not restored, user will need to scroll manually.",
  );
}
```

### Prevent automatic page location restoration


```js
if (history.scrollRestoration) {
  history.scrollRestoration = "manual";
}
```

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

| Specification |
| --- |
| HTML Standard # dom-history-scroll-restoration-dev |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
History: replaceState() method
==============================

 The **`replaceState()`** method of the `History` interface modifies the current
 history entry, replacing it with the state object and
 URL passed in the method parameters. This method is particularly useful
 when you want to update the state object or URL of the current history entry in response
 to some user action.

Syntax
------


```js
replaceState(state, unused)
replaceState(state, unused, url)
```

### Parameters

`state`

 An object which is associated with the history entry
 passed to the `replaceState()` method. The state object can be
 `null`.


`unused`

This parameter exists for historical reasons, and cannot be omitted; passing the empty string is traditional, and safe against future changes to the method.

`url` Optional

 The URL of the history entry. The new URL must be of the same origin as the current
 URL; otherwise the `replaceState()` method throws an exception.


### Return value

None (`undefined`).

### Exceptions

`SecurityError` `DOMException`

Thrown if the associated document is not fully active, or if the provided `url` parameter is not a valid URL.

`DataCloneError` `DOMException`

Thrown if the provided `state` parameter is not serializable.

Examples
--------

Suppose `https://www.mozilla.org/foo.html` executes the following JavaScript:


```js
const stateObj = { foo: "bar" };
history.pushState(stateObj, "", "bar.html");
```


On the next page you could then use `history.state` to access the `stateObj` that was just added.

 The explanation of these two lines above can be found in the Working with the History API article. Then suppose
 `https://www.mozilla.org/bar.html` executes the following
 JavaScript:


```js
history.replaceState(stateObj, "", "bar2.html");
```


 This will cause the URL bar to display
 `https://www.mozilla.org/bar2.html`, but won't cause the browser
 to load `bar2.html` or even check that `bar2.html` exists.

 Suppose now that the user navigates to
 `https://www.microsoft.com`, then clicks the Back button. At this
 point, the URL bar will display `https://www.mozilla.org/bar2.html`.
 If the user now clicks Back again, the URL bar will
 display `https://www.mozilla.org/foo.html`, and totally bypass bar.html.

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

| Specification |
| --- |
| HTML Standard # dom-history-replacestate-dev |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
History: back() method
======================

 The **`back()`** method of the `History` interface causes
 the browser to move back one page in the session history.

 It has the same
 effect as calling `history.go(-1)`. If there is no previous
 page, this method call does nothing.

 This method is asynchronous. Add a listener for the
 `popstate` event in order to determine when the navigation has completed.

Syntax
------


```js
back()
```

### Parameters

None.

### Return value

None (`undefined`).

### Exceptions

`SecurityError` `DOMException`

Thrown if the associated document is not fully active.

Examples
--------

 The following short example causes a button on the page to navigate back one entry in
 the session history.

### HTML


```html
<button id="go-back">Go back!</button>
```

### JavaScript


```js
document.getElementById("go-back").addEventListener("click", () => {
  history.back();
});
```

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

| Specification |
| --- |
| HTML Standard # dom-history-back-dev |

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

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

See also
--------

* `History`
* Working with the History API
History: length property
========================

 The **`length`** read-only property of the `History` interface
 returns an integer representing the number of elements in the session
 history, including the currently loaded page.

For example, for a page loaded in a new tab this property returns `1`.

Value
-----

A number.

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

| Specification |
| --- |
| HTML Standard # dom-history-length-dev |

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

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

See also
--------

* The `History` interface it belongs to.
History: go() method
====================

 The **`go()`** method of the `History` interface loads a specific page from the
 session history. You can use it to move forwards and backwards through the history
 depending on the value of a parameter.

 This method is asynchronous. Add a listener for the
 `popstate` event in order to determine when the navigation has completed.

Syntax
------


```js
go()
go(delta)
```

### Parameters

`delta` Optional

 The position in the history to which you want to move, relative to the current page.
 A negative value moves backwards, a positive value moves forwards. So, for example,
 `history.go(2)` moves forward two pages and `history.go(-2)`
 moves back two pages. If no value is passed or if `delta` equals 0, it has
 the same result as calling `location.reload()`.


### Return value

None (`undefined`).

### Exceptions

`SecurityError` `DOMException`

Thrown if the associated document is not fully active.

Examples
--------

To move back one page (the equivalent of calling `back()`):


```js
history.go(-1);
```


To move forward a page, just like calling `forward()`:


```js
history.go(1);
```


To move forward two pages:


```js
history.go(2);
```


To move backwards by two pages:


```js
history.go(-2);
```


And, finally either of the following statements will reload the current page:


```js
history.go();
history.go(0);
```

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

| Specification |
| --- |
| HTML Standard # dom-history-go-dev |

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

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

See also
--------

* `History`
* `back()`
* `forward()`
* `popstate` event
* Working with the History API
VREyeParameters: minimumFieldOfView property
============================================

**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.

**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The **`minimumFieldOfView`** read-only property of the `VREyeParameters` interface describes the minimum supported field of view for the current eye.

**Note:** This property was part of the old WebVR API. It has been superseded by the WebXR Device API.

Value
-----

A `VRFieldOfView` object.

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

This property was part of the old WebVR API that has been superseded by the WebXR Device API. It is no longer on track to becoming a standard.

Until all browsers have implemented the new WebXR APIs, it is recommended to rely on frameworks, like A-Frame, Babylon.js, or Three.js, or a polyfill, to develop WebXR applications that will work across all browsers [1].

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

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

See also
--------

* WebVR API
* `VRFieldOfView`