There are two ways to register a background page in the extension manifest.
The scripts
property
In the common case, a background page doesn't require any HTML markup. We can register these kinds of background pages using the scripts
property.
In this case, a background page will be generated by the extension system that includes each of files listed in the scripts
property.
{
...
"background": {
"scripts": ["background1.js", "background2.js"],
"persistent": true
},
...
}
The page
property
In some cases, we may want to specify HTML in background page, we can achieve that using the page
property.
{
...
"background": {
"page": "background.html",
"persistent": true
},
...
}
scripts
VS page
It's hard to say which one is better. we could use page
property and have some elements declared in HTML page for future use. We could also dynamically create such elements in the scripts without explicitly declaring HTML page. It all depends on the actual needs.