web api instance method
NavigationPreloadManager: disable() method
Secure contextAvailable in 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
disable()
Parameters
None.
Return value
A Promise that resolves with undefined.
Exceptions
InvalidStateErrorDOMException- : There is no active worker associated with the registration to which this
NavigationPreloadManagerbelongs.
- : There is no active worker associated with the registration to which this
Examples
The code below shows how to disable preloading, after first using 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
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.