Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. NavigationPreloadManager
  4. disable()

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).

Syntax

js
disable()

Parameters

None.

Return value

APromise that resolves withundefined.

Exceptions

InvalidStateErrorDOMException

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

Examples

The code below shows how to disable preloading, after first usingServiceWorkerRegistration.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 Nightly
# dom-navigationpreloadmanager-disable

Browser compatibility

See also

NavigationPreloadManager.enable()

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp