We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE


この翻訳は不完全です。英語から この記事を翻訳 してください。

種類 Object
必須 No
"background": {
  "scripts": ["background.js"]

background を使って拡張機能に1つ以上のバックグラウンドスクリプトや、オプションとしてバックグラウンドページを含めます。

Background scripts are the place to put code that needs to maintain 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. You can use any of the WebExtension APIs in the script, as long as you have requested the necessary permissions.

See the "Background pages" section in Anatomy of an extension for some more details.

The background key is an object that may have one of the following two properties, both optional:


An array of strings, each of which is a path to a JavaScript source. The path is relative to the manifest.json file itself. These are the background scripts that will be included in the extension.

The scripts share the same window global.

The scripts are loaded in the order they appear in the array.

Note that there is a bug affecting Firefox versions earlier than 50: when the Firefox debugger is open, scripts are not always loaded in the order given in the array. To work around this bug, you can use the "page" property and include background scripts from the page using <script> tags. This bug is fixed in Firefox 50, and from that point on, scripts are always loaded in the order given in the array.

注: If you want to fetch a script from a remote location with the <script> tag (e.g. <script src = "https://code.jquery.com/jquery-1.7.1.min.js">), you will also have to change the content_security_policy key in the manifest.json file of your extension.


If you specify "scripts", then an empty page will be created for your scripts to run in.

If you need some particular content in the page, you can define your own page using the "page" option.

If you use this property, you can no longer specify background scripts using "scripts", but you can  include your own scripts from the page, just like in a normal web page.

  "background": {
    "scripts": ["jquery.js", "my-background.js"]

Load two background scripts.

  "background": {
    "page": "my-background.html"

Load a custom background page.


ChromeEdgeFirefoxFirefox for AndroidOpera
基本対応 あり あり14848 あり
persistent あり あり なし なし あり

1. The 'persistent' property is mandatory.


 このページの貢献者: Uemmra3
 最終更新者: Uemmra3,