The port property of the SharedWorker interface returns a MessagePort object used to communicate and control the shared worker.




A MessagePort object.


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:

var myWorker = new SharedWorker('worker.js');

For a full example, see our Basic shared worker example (run shared worker.)


Specification Status Comment
HTML Living Standard
The definition of 'AbstractWorker.onerror' in that specification.
Living Standard  

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 4Edge ? Firefox Full support 29IE Full support 10Opera Full support 10.6Safari No support 5 — 6.1WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 33Opera Android Full support 11.5Safari iOS No support 5.1 — 7.1Samsung Internet Android Full support Yes


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Contributors to this page: fscholz, nmve, Sebastianz, julienw, chrisdavidmills, kscarfone
Last updated by: fscholz,