Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmihal/Subworkers
Polyfill to allow nested WebWorkers
https://github.com/dmihal/Subworkers
Last synced: 3 months ago
JSON representation
Polyfill to allow nested WebWorkers
- Host: GitHub
- URL: https://github.com/dmihal/Subworkers
- Owner: dmihal
- License: mit
- Created: 2015-02-20T07:13:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-01T10:46:04.000Z (almost 2 years ago)
- Last Synced: 2024-07-18T01:52:56.009Z (4 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 83
- Watchers: 3
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Subworkers
WebWorkers are awesome! Unfortionately, Google Chrome doesn't support creating subworkers,
[here's the Chromium issue for it](https://code.google.com/p/chromium/issues/detail?id=31666).This polyfill provides this functionality to Chrome and any other browser that supports WebWorkers,
but not subworkers. This functionality is implemented by creating all subworkers in the context of
the main page and simulating the communication.## Usage
Using this is easy!1. Download [`subworkers.js`](https://raw.githubusercontent.com/dmihal/Subworkers/master/subworkers.js)
2. In the document hosting the WebWorkers, include the `subworkers.js` script before any scripts that create WebWorkers.``` html
```3. In the code for any WebWorker that will have a subworker, you also need to include `subworkers.js`.
``` javascript
importScripts("subworkers.js");
```That's it! WebWorkers now work the way you would expect!
### With NPM
1. Install subworkers.js by running `npm install -s subworkers`
2. Import the library in all scripts``` javascript
require('subworkers'); // CommonJS
// or
import 'subworkers'; // ES2015+
```## License
This project is released under the MIT License.