This project demonstrates the use of a Shared Worker in a web application. A Shared Worker allows multiple scripts to communicate with each other and share a single worker thread.
index.html
: The main HTML file that sets up the user interface.index.js
: The JavaScript file that handles the interaction between the user interface and the Shared Worker.worker.js
: The Shared Worker script that manages messages between different clients.
The project must be run on the server. You can use one of the solutions that suits you.
- Using Node.js http-server.
- Using Python's SimpleHTTPServer.
- Using Live Server Extension in VS Code.
- Open
index.html
in a web browser that supports Shared Workers. - Open multiple tabs with the same
index.html
file to see the Shared Worker in action.
- Multiple clients can connect to the Shared Worker.
- Messages sent from one client are broadcasted to all connected clients.
- The user interface updates in real-time to display messages from all clients.
This project requires a browser that supports Shared Workers. If Shared Workers are not supported, an error message will be displayed in the console.
This project is licensed under the MIT License.