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 2022.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Note: This feature is available inWeb Workers.
Thedisable() method of theNavigationPreloadManager interface halts the automatic preloading of service-worker-managed resources previously started usingenable()It returns a promise that resolves withundefined.
The method may be called in the service worker'sactivate event handler (before thefetch event handler can be called).
In this article
Syntax
disable()Parameters
None.
Return value
Exceptions
InvalidStateErrorDOMExceptionThere is no active worker associated with the registration to which this
NavigationPreloadManagerbelongs.
Examples
The code below shows how to disable preloading, after first usingServiceWorkerRegistration.navigationPreload to test that it is supported.
addEventListener("activate", (event) => { event.waitUntil( (async () => { if (self.registration.navigationPreload) { // Disable navigation preloads! await self.registration.navigationPreload.disable(); } })(), );});Specifications
| Specification |
|---|
| Service Workers Nightly> # dom-navigationpreloadmanager-disable> |
Browser compatibility
See also
NavigationPreloadManager.enable()