Article.EWA.JavaScript.WebWorkersApp
This repository shows how to implement the Real-Time WebSocket API with JavaScript web browser using HTML Web Workers to handle a connection logic in a separate thread.
Install / Use
/learn @LSEG-API-Samples/Article.EWA.JavaScript.WebWorkersAppREADME
Real-time WebSocket API with Web Workers Example
- Last update: Feb 2025
- Environment: Any
- Compiler: JavaScript
- Prerequisite: Real-Time Advanced Distribution servers version 3.2.1 and above
Overview
Websocket API for Pricing Streaming and Real-Time Service aka Websocket API application enables easy integration into a multitude of client technology environments such as scripting and web. This API runs directly on your Real-Time infrastructure and presents data in an open (JSON) readable format. The API supports all Real-Time data models and can be integrated into multiple client technology standards e.g. Python, R, .Net, etc.
The web browser's JavaScript runtime is a single-threaded environment by default. However, the HTML standard lets developers implement multi-threads JavaScript application in the web browser by introducing the Web Workers feature that lets web browsers run JavaScripts in the main thread and a background thread (workers thread).
This example shows how to implement the Real-time WebSocket API with JavaScript web application with Web Workers. It allows the Web Workers thread to handle the connection logic with eal-Time Advanced Distribution server while the main thread handles the UI interaction events and displaying data.
There are two types of Web Workers, Dedicated Workers and Shared Workers. This example covers only how to implement the Real-time WebSocket API with JavaScript web browser application with Dedicated Workers.
Supported Web Browsers
The example supports Chrome/Microsoft Edge (Chrome-based version), Firefox, and IE11 (based on the WebSocket and Web Workers browser supported platform).
Prerequisite
This example requires the following dependencies software.
- Node.js runtime - version 8.9.3 or higher.
- npm package manager (included with Node.js runtime)
- Express.js framework (will be installed via
npm installcommand)
This example also uses the following 3rd party libraries for UI presentation.
- jQuery 3.2.1 JavaScript library
- Bootstrap 3.3.7 CSS library
jQuery,Bootstrap and Express.js are distributed under the MIT license. Please see more detail in the LICENSE.md file.
Example files and folders
The web application contains the following example files and folder:
- index.html: The application HTML page
- app/market_price_app.js: The application main file
- app/ws_workers.js: The application Web Workers file
- css/cover.css: The application CSS file
- libs/jquery-3.2.1.min.js: jQuery library file
- bootstrap/css, bootstarp/fonts and bootstrap/js folders: The folders for Bootstrap CSS and libraries files
- server.js: A simple web server application
- package.json: The Project npm dependencies file.
How to run this example
- Unzip or download the example project folder into a directory of your choice
- Run
$> npm installin the command prompt to install all the dependencies required to run the sample in a subdirectory called node_modules/.

- If the machine is behind a proxy server, you need to configure Node.js uses proxy instead of a direct HTTP connection via the following command in a command prompt:
set https_proxy=http://<proxy.server>:<port> - Run
$> node server.jsin the command prompt to start the webserver at HTTP port 8080

- Open the web browser (IE11, Chrome/Microsoft Edge (Chrome-based version), and Firefox), then navigate to index.html of the web server at
http://localhost:8080/index.html

References
For further details, please check out the following resources:
- LSEG Real-Time products page on the LSEG Developer Community web site.
- WebSocket API page.
- Developer Webinar Recording: Introduction to Electron Websocket API
- Mozilla Developer Network: Web Workers API page.
- Google HTML5 Rocks: The Basics of Web Workers page
- Mozilla Developer Network: WebSocket API page
For any questions related to this article or the WebSocket API page, please use the Developer Community Q&A Forum.
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
Languages
Security Score
Audited on Mar 31, 2026
