Skip to content

About

Advanced JS Execution: Promises, Workers, and Comlink

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Advanced Execution in JS: Promises and Web Workers

This GitHub repo is the companion to ARTICLE.md: a short article plus runnable examples for Promises, Web Workers, Comlink, SharedArrayBuffer, workerpool, and Piscina.

Clone the repo, open an example folder, and run it while you read.

Examples

# Project What it shows Runtime
01 examples/01-main-thread-freeze Heavy loop wrapped in async still freezes the UI Browser
02 examples/02-raw-web-worker Same work via postMessage stays responsive Browser
03 examples/03-comlink-worker RPC-style API with Comlink (wrap / expose) Browser
04 examples/04-shared-array-buffer Shared memory + COOP/COEP headers Browser
05 examples/05-workerpool Job queue across a pool of workers Browser
06 examples/06-piscina-node Node.js worker_threads pool with Piscina Node

Quick start

git clone git@github.com:mrajaeim/Advanced-JS-Execution.git
cd Advanced-JS-Execution

Each browser example uses Vite:

cd examples/02-raw-web-worker
npm install
npm run dev

Node example:

cd examples/06-piscina-node
npm install
npm start

Requirements

  • Node.js 18+
  • A modern Chromium-based browser for SharedArrayBuffer (example 04 needs cross-origin isolation; Vite already sets the headers)

Article

Read the full write-up: Why Promises Do Not Free Your UI (and When Web Workers Do)

Related

Call stack, microtasks/macrotasks, and the event loop: Why Your JavaScript Runs in the Wrong Order

License

MIT

About

Advanced JS Execution: Promises, Workers, and Comlink

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors