Web Worker Fibonacci Demo - Online Non‑Blocking Calculation
Calculate large Fibonacci numbers in a Web Worker. See the UI remain responsive. Copy the pattern for your app.
UD5 Toolkit
Non-blocking — UI stays responsive
Blocking — UI freezes during computation
| Metric | With Worker | Without Worker |
|---|---|---|
| Execution Time | — | — |
| Primes Found | — | — |
| UI Remained Responsive | Yes | No — Froze |
| User Could Interact | Yes | No |
| Can Be Cancelled | Yes (terminate) | No |
postMessage() and onmessage.
window object, or document directly. They cannot manipulate HTML elements. Communication is limited to structured cloning of data via messages. They cannot access localStorage or sessionStorage directly (though they can use IndexedDB). Each worker also consumes additional memory and has a startup cost.
navigator.hardwareConcurrency to detect the number of available logical cores. For truly parallel processing, divide your work across multiple workers — each runs independently on a separate thread. Just be mindful of memory overhead per worker.
worker.terminate() from the main thread to immediately stop a worker. This kills the worker thread instantly without allowing any cleanup inside the worker. Alternatively, you can implement a cooperative cancellation pattern by sending a custom message (e.g., {cmd: 'stop'}) and having the worker check for it periodically during its computation.
Calculate large Fibonacci numbers in a Web Worker. See the UI remain responsive. Copy the pattern for your app.
Divide your day into blocks with color codes. Drag tasks into slots. See free time at a glance.
Place multiple grid items into the same cells to create overlapping layouts. Learn the technique visually. Copy code.
Render 1000 styled elements using inline styles vs. CSS classes and compare time. Understand CSS‑in‑JS trade‑offs.
Control image‑orientation: from-image vs none. See how the browser interprets EXIF rotation. Fix portrait photos.
Configure how your PWA launches: focus existing or create new. Test with the launch_handler manifest field.
Build a horizontal scroll‑snap container with configurable snap‑type and alignment. Perfect for image galleries.
Compare all CSS easing presets side by side on a bouncing ball. See which curve fits your UI animation.
Query the permission state of camera, microphone, geolocation, and more. See the response and learn the API.
Process audio faster than real‑time with OfflineAudioContext. Apply filters and export the result. Dev tool.
Drop files onto a zone and see a preview with name, size, and type. Copy the JavaScript pattern for your site.
Demonstrate how to add custom headers and POST‑like functionality to EventSource using a polyfill. Code and example.
Scroll a container and see how sticky elements behave. Adjust top, bottom, and scroll margins. Copy the code.
See how overflow: visible, hidden, scroll, and auto behave with real content. Clone to test with your text.
See the difference between clone and slice on inline boxes that break across lines. Useful for multi‑line headings.
Adjust page characteristics (image size, server delay, layout shift) and see the simulated Core Web Vitals scores. Understand what impacts performance.
Render the classic Stanford Bunny with a basic WebGPU pipeline. Rotate and zoom. Check if your browser supports WebGPU.
See how scroll‑padding and scroll‑margin affect the position of elements when using anchor links or scroll‑snap. Visual.
Test a regex against long strings and measure execution time. Detect catastrophic backtracking patterns. Visual warning if slow.
Test the experimental Translation API to translate text between languages directly in the browser, without cloud calls. Check support and copy the JavaScript starter.
Apply a convolution filter (blur, sharpen) using a Web Worker. See the UI stay responsive while processing. Learn multithreading in the browser.
Measure your browser's GPU compute power using a simple WebGPU matrix multiplication. See raw FLOPS and compare with peers. Fully client‑side.
Paste a raster image and an SVG, see the file size and rendering time. Understand when to use vector. Local.
Apply will‑change to any element and see its effect on compositing. Learn best practices for smooth animations.
Toggle scrollbar‑gutter: stable to reserve space for the scrollbar and avoid content jumps. Visual demo with two columns.
Acquire and release locks across tabs. Prevent race conditions in IndexedDB or localStorage. Visual queue and lock state.
Register a periodic background sync to fetch fresh data even when the tab is closed. Understand the API and limits.
Test the Fullscreen API: request fullscreen on a colored div, detect changes, and copy the JavaScript boilerplate.
See the View Transitions API in action. Cross‑fade and morph between two states. Copy the JavaScript starter code.
Enter a URL and get a one‑page report of titles, description, headings, image alts, and broken links. All from browser.