A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/en-US/docs/Web/API/NavigationPreloadManager/getState below:

NavigationPreloadManager: getState() method - Web APIs

NavigationPreloadManager: getState() method

Baseline Widely available

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

Note: This feature is available in Web Workers.

The getState() method of the NavigationPreloadManager interface returns a Promise that resolves to an object with properties that indicate whether preload is enabled and what value will be sent in the Service-Worker-Navigation-Preload HTTP header.

Syntax Parameters

None.

Return value

A Promise that resolves with an object that has the following properties:

enabled

true if preloading is enabled, and false otherwise.

A string containing the value that will be sent in the Service-Worker-Navigation-Preload HTTP header following a preloading fetch(). This defaults to true unless the value was changed using NavigationPreloadManager.setHeaderValue().

Exceptions
InvalidStateError DOMException

There is no active worker associated with the registration to which this NavigationPreloadManager belongs.

Examples

The code below shows a request for the current state, made once the service worker is ready.

navigator.serviceWorker.ready
  .then((registration) => registration.navigationPreload.getState())
  .then((state) => {
    console.log(state.enabled); // boolean
    console.log(state.headerValue); // string
  })
  .catch((e) =>
    console.error(`NavigationPreloadManager not supported: ${e.message}`),
  );
Specifications Browser compatibility

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4