The offscreen permission allows a Manifest V3 extension to create and manage an offscreen document. This is a special, hidden HTML page that runs in the background.
What it does
- Provides a way for service workers to access DOM APIs, which service workers themselves do not have access to.
- An offscreen document can interact with the clipboard, play audio, or process content within an iframe, among other things.
- An extension can only have one offscreen document open at a time.
When to use it
Use this permission when your service worker needs to perform a task that requires a DOM, which was previously handled by background pages in Manifest V2.
Examples:
- An extension that needs to programmatically copy text or images to the clipboard.
- An extension that plays short audio clips for notifications.
- An extension that needs to scrape data from a website by loading it into a hidden
<iframe>.
Manifest Declaration
{
"name": "My Offscreen Extension",
"version": "1.0",
"manifest_version": 3,
"permissions": [
"offscreen"
]
}Security & Privacy
Why is it not risky?
This is a technical permission that allows modern extensions to perform certain background tasks, like copying text to your clipboard or playing a notification sound. It works by creating a tiny, invisible webpage to do the job.
By itself, this permission is safe and does not grant any new capabilities. The real risk depends on what the extension does with this invisible page. For example, if it's used to read your clipboard, then the risk comes from that clipboard access, not from this permission alone.
API Usage Example
This shows how a service worker can create an offscreen document to perform a task.
// background.js
async function createOffscreen() {
if (await chrome.offscreen.hasDocument()) return;
await chrome.offscreen.createDocument({
url: 'offscreen.html',
reasons: ['CLIPBOARD'],
justification: 'Reason for needing the document',
});
}
// You would call createOffscreen() before needing to do
// something like read from the clipboard.Extensions with the offscreen permission
Here are some popular browser extensions that use the "offscreen" permission. To explore more, try our Advanced search.