e01.org

NavigationPreloadManager: disable() method

Service Workers API

Service Workers API

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-nolint
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

## Browser compatibility

## See also

- NavigationPreloadManager.enable()

source: MDN Web Docs mirror · page

Cite this

"NavigationPreloadManager: disable() method". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/NavigationPreloadManager/disable

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy