"web_accessible_resources": [ "images/my-image.png" ]
For example, the "beastify" example extension replaces a web page with images of some beasts, by adding some
<img> elements whose
src attribute points to the images. The images are packaged with the extension, and for the web page to be able to load them, they must be made web accessible.
web_accessible_resources key lists all packaged resources that you want to make available to web pages in this way. You specify them as paths relative to the manifest.json file.
Note that content scripts don't need to be listed as web accessible resources.
However, if an extension wants to use the
webRequest API to redirect a public (e.g. HTTPS) URL to a page that's packaged in the extension, then the extension must list the page in your
For example, suppose your extension includes an image file at images/my-image.png, like this:
my-extension-files/ manifest.json my-background-script.js images/ my-image.png
To enable a web page to contain an
<img> element whose
src attribute points to this image, you could specify "web_accessible_resources" like this:
The file will then be available using a URL like:
<extension-UUID> is not your extension's ID. It is randomly generated for every browser instance. This prevents websites from fingerprinting a browser by examining the extensions it has installed.
The easiest way to get this URL from inside your extension is to use the
browser.extension.getURL API, and give it the path relative to manifest.json:
browser.extension.getURL("images/my-image.png"); // something like: // moz-extension://944cfddf-7a95-3c47-bd9a-663b3ce8d699/images/my-image.png
web_accessible_resources entries can contain wildcards. For example, the following entry would also work to include the resource at "images/my-image.png":
Note that if you make a page web-accessible, then any website may then link or redirect to that page. The page should then treat any input (POST data, for examples) as if it came from an untrusted source, just as a normal web page should.
Make the file at "images/my-image.png" web accessible.
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
|Chrome||Edge||Firefox||Opera||Firefox for Android|
|Basic support||Chrome Full support Yes||Edge Full support 14||Firefox Full support 48||Opera Full support Yes||Firefox Android Full support 48|
- Full support
- Full support