Skip to content

Files

Latest commit

author
AndrewBubnov
Feb 12, 2025
5c8aef4 · Feb 12, 2025

History

History
34 lines (21 loc) · 1.29 KB

README.md

File metadata and controls

34 lines (21 loc) · 1.29 KB

Shared Worker Lesson

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.

Project Structure

  • 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.

How to Run

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.
  1. Open index.html in a web browser that supports Shared Workers.
  2. Open multiple tabs with the same index.html file to see the Shared Worker in action.

Features

  • 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.

Browser Support

This project requires a browser that supports Shared Workers. If Shared Workers are not supported, an error message will be displayed in the console.

License

This project is licensed under the MIT License.