Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jsmith01/broadcastchannel-polyfill
Simple BroadcastChannel polyfill for browsers with MessageChannel API onboard
https://github.com/jsmith01/broadcastchannel-polyfill
broadcastchannel polyfill
Last synced: 24 days ago
JSON representation
Simple BroadcastChannel polyfill for browsers with MessageChannel API onboard
- Host: GitHub
- URL: https://github.com/jsmith01/broadcastchannel-polyfill
- Owner: JSmith01
- License: unlicense
- Created: 2019-03-07T10:31:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-08T07:34:46.000Z (about 4 years ago)
- Last Synced: 2024-09-19T10:19:01.966Z (2 months ago)
- Topics: broadcastchannel, polyfill
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 34
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
BroadcastChannel polyfill
===================================This is a polyfill for [BroadcastChannel](https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API).
**It is just a published copy of [Joshua Bell's gist](https://gist.github.com/inexorabletash/52f437d1451d12145264)**
(since [broadcast-channel polyfill](https://www.npmjs.com/package/broadcast-channel) won't work for our project).It requires [Message Channel support](http://caniuse.com/#feat=channel-messaging), so should work in:
* Chrome 4+
* Safari 5+
* Opera 11.5+Does not work in:
* Firefox 37- (neither BroadcastChannel nor MessageChannel)
* IE (??)### Caveats ###
* The real API should let you transmit anything which can copied by the [structured cloning algorithm](https://html.spec.whatwg.org/multipage/infrastructure.html#structured-clone). This polyfill only copies things using `JSON.stringify()`/`JSON.parse()` so it is much more limited.
* This polyfill uses [DOM Storage](https://html.spec.whatwg.org/multipage/#toc-webstorage) (`localStorage`) and `storage` events. DOM Storage is a synchronous API and so may cause performance issues in pages. In addition, it is not exposed to Workers. Therefore, the polyfill will not function in Workers.
* Unique storage keys are used for each message, and are cleaned up a few hundred milliseconds after transmission. This is a total hack and may result in the messages failing to be received (if the write and delete are coalesced) or persisting (if the cleanup is prevented by page close).