A RetroSearch Logo

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

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/NavigationPreloadManager/enable below:

NavigationPreloadManager: enable() method - Web APIs

NavigationPreloadManager: enable() 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 enable() method of the NavigationPreloadManager interface is used to enable preloading of resources managed by the service worker. It returns a promise that resolves with undefined.

The method should be called in the service worker's activate event handler, which ensures it is called before any fetch event handler can fire.

Syntax Parameters

None.

Return value

A Promise that resolves with undefined.

Exceptions
InvalidStateError DOMException

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

Examples

The code below shows how to enable preloading, after first using ServiceWorkerRegistration.navigationPreload to test that it is supported.

addEventListener("activate", (event) => {
  event.waitUntil(
    (async () => {
      if (self.registration.navigationPreload) {
        // Enable navigation preloads!
        await self.registration.navigationPreload.enable();
      }
    })(),
  );
});
Specifications Browser compatibility See also

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