SharedWorker: port property
The port
property of the SharedWorker
interface returns a MessagePort
object used to communicate and control
the shared worker.
Value
A MessagePort
object.
Examples
The following code snippet shows creation of a SharedWorker
object using
the SharedWorker()
constructor. Multiple
scripts can then access the worker through a MessagePort
object accessed
using the SharedWorker.port
property — the port is started using its
start()
method:
js
const myWorker = new SharedWorker("worker.js");
myWorker.port.start();
For a full example, see our Basic shared worker example (run shared worker.)
Specifications
Specification |
---|
HTML Standard # dom-sharedworker-port-dev |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
port |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Has more compatibility info.
The compatibility table on 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.