background
Type | Object |
---|---|
Mandatory | No |
Manifest version | 2 or higher |
Example |
json
|
Use the background
key to include one or more background scripts or a background page in your extension.
Background scripts are the place to put code that needs to maintain a long-term state, or perform long-term operations, independently of the lifetime of any particular web pages or browser windows.
Background scripts are loaded as soon as the extension is loaded and stay loaded until the extension is disabled or uninstalled unless persistent
is specified as false
. You can use any WebExtension APIs in the script as long as you have requested the necessary permissions.
See Background scripts for some more details.
The background
key is an object that must have one of these properties:
scripts |
An The scripts share the same The scripts are loaded in the order they appear in the array.
If you specify
Note: If you want to fetch a script from a remote
location with the |
page |
If you need specific content in the background page, you can define a
page using the
If you use this property, you can not specify background scripts using
|
The background
key can also contain this optional property:
persistent |
A If omitted, this property default to
|
type |
A Determines whether the scripts specified in
If omitted, this property defaults to |
Example
json
"background": {
"scripts": ["jquery.js", "my-background.js"]
}
Load two background scripts.
json
"background": {
"page": "my-background.html"
}
Load a custom background page.
Browser compatibility
BCD tables only load in the browser