mdn.go-v.org

`script.removePreloadScript` command

The script.removePreloadScript command of the script module removes the specified preload script.

source: MDN Web Docslicence: CC BY-SA 2.5+ (MDN)database: /home/dbs/mdn.dbmode: tablerecords: 14753 (max_rowid)citation: https://developer.mozilla.org/

The script.removePreloadScript command of the script module removes the specified preload script.

Full text

The `script.removePreloadScript` [command](/docs/Web/WebDriver/Reference/BiDi/Modules#commands) of the [`script`](/docs/Web/WebDriver/Reference/BiDi/Modules/script) module removes the specified preload script.

## Syntax

```json-nolint
/* With required parameters */
{
"method": "script.removePreloadScript",
"params": {
"script": "d4b1a0f6-2a3c-4f7d-9e21-5c6b7a8d9e0f"
}
}
```

### Parameters

The `params` field contains:

- `script`
- : A string that contains the [UUID](/docs/Glossary/UUID) of the preload script to remove.
Preload script IDs are returned by the [`script.addPreloadScript`](/docs/Web/WebDriver/Reference/BiDi/Modules/script/addPreloadScript) command.

### Return value

The `result` field in the response is an empty object (`{}`).

### Errors

- [`invalid argument`](/docs/Web/WebDriver/Reference/Errors/InvalidArgument)
- : Thrown if a required parameter is missing or has an invalid type.
- `no such script`
- : Thrown if no preload script with the specified script ID is found.

## Description

After a [preload script](/docs/Web/WebDriver/Reference/BiDi/Modules/script#preload_scripts) is removed, the browser no longer runs it in new documents.
Removing a preload script does not undo changes it has already made.

When a session ends, the browser automatically removes all preload scripts registered in that session.

## Examples

### Removing a preload script

Assume you have a [WebDriver BiDi connection](/docs/Web/WebDriver/How_to/Create_BiDi_connection) and an [active session](/docs/Web/WebDriver/Reference/BiDi/Modules/session/new).

Suppose you registered a preload script that logs each new document's URL by using [`script.addPreloadScript`](/docs/Web/WebDriver/Reference/BiDi/Modules/script/addPreloadScript).
The browser returns the preload script's ID in the `script` field.

To stop logging URLs for new documents, send the following message to remove the preload script:

```json
{
"id": 3,
"method": "script.removePreloadScript",
"params": {
"script": "d4b1a0f6-2a3c-4f7d-9e21-5c6b7a8d9e0f"
}
}
```

The browser responds with an empty `result` object:

```json
{
"id": 3,
"type": "success",
"result": {}
}
```

When you subsequently navigate a context to a new document, the removed preload script no longer logs the document's URL.

## Specifications

## Browser compatibility

## See also

- [`script.addPreloadScript`](/docs/Web/WebDriver/Reference/BiDi/Modules/script/addPreloadScript) command
- [`script.evaluate`](/docs/Web/WebDriver/Reference/BiDi/Modules/script/evaluate) command
- [`script.callFunction`](/docs/Web/WebDriver/Reference/BiDi/Modules/script/callFunction) command

Fields

page_typewebdriver-command
tags
source: MDN Web Docslicence: CC BY-SA 2.5+ (MDN)year: —id: Web/WebDriver/Reference/BiDi/Modules/script/removePreloadScriptcitation: https://developer.mozilla.org/en-US/docs/Web/WebDriver/Reference/BiDi/Modules/script/removePreloadScript

JSON · full text · full-text JSON

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.