NavigationPreloadManager: disable() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

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 disable() method of the NavigationPreloadManager interface halts the automatic preloading of service-worker-managed resources previously started using enable() It returns a promise that resolves with undefined.

The method may be called in the service worker's activate event handler (before the fetch event handler can be called).

Syntax

js
disable()

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 disable preloading, after first using ServiceWorkerRegistration.navigationPreload to test that it is supported.

js
addEventListener("activate", (event) => {
  event.waitUntil(
    (async () => {
      if (self.registration.navigationPreload) {
        // Disable navigation preloads!
        await self.registration.navigationPreload.disable();
      }
    })(),
  );
});

Specifications

Specification
Service Workers
# dom-navigationpreloadmanager-disable

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
disable

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also