Skip to main content

Background Script API

Background scripts are loaded when the Repl opens. They remain permanently loaded until the extension is uninstalled or you close the workspace.

Background scripts are written in a “background page”, which is an “invisible” iFrame context that renders no UI.

You can add a background page to your extension by adding the following field to your Manifest file:

{
...
"background": {
"page": "/path/to/background.html"
}
...
}

The path points to a page in your extension bundle. We load it as an invisible iframe element; if you render any UI elements, they will not be visible to users. (To render UI, you want to create tools instead).

Here’s an example extension that makes use of the background script: