Firefox Tomorrow

web api instance method

NavigationPreloadManager: enable() method

View on MDN ↗

Secure contextAvailable in workers

The enable() method of the NavigationPreloadManager interface is used to enable preloading of resources managed by the service worker. It returns a promise that resolves with undefined.

The method should be called in the service worker’s activate event handler, which ensures it is called before any fetch event handler can fire.

Syntax

enable()

Parameters

None.

Return value

A Promise that resolves with undefined.

Exceptions

Examples

The code below shows how to enable preloading, after first using navigationPreload to test that it is supported.

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

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also

disable()