webRequest.StreamFilter.suspend()

Suspends a request. After this is called, no more data will be delivered until the request is resumed with a call to resume().

You can't call this function until after the onstart event has fired.

Syntax

filter.suspend()

Parameters

None.

Return value

None.

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
suspend
No
No
57
?
No
No
?
?
57
?
?
?

Examples

This example uses suspend/resume to delay a web request.

function listener(details) {
  let filter = browser.webRequest.filterResponseData(details.requestId);

  filter.onstart = event => {
    filter.suspend();

    setTimeout(() => {
      filter.resume();
      filter.disconnect();
    }, 1000);

  }
}

browser.webRequest.onBeforeRequest.addListener(
  listener,
  {urls: ["https://example.org/"], types: ["main_frame"]},
  ["blocking"]
);

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/StreamFilter/suspend