HTML 5 Web Worker — The Basics

Web Worker is a simple method that allows websites to run scripts in the background.

Lin Dane
11 min readSep 6, 2024
Photo by Fatos Bytyqi on Unsplash

Workers operate independently of the user interface, meaning they can execute tasks without interacting with or disrupting the UI.

In this article, we will explore some basic uses of web workers.

The Problem: JavaScript Parallelism

Web applications can suffer from performance issues, leading to bottlenecks that make even the best-designed web applications difficult for users due to low efficiency. These issues may arise from the server (e.g., heavy processing, poor optimization) or from client-side JavaScript.

In this article, we will focus on JavaScript-specific issues, which can include browser compatibility and JavaScript engine performance. Fortunately, most of these issues have diminished over time as CPUs have become more powerful and modern browsers have significantly improved JavaScript engine performance. Even the once-dreaded Microsoft browsers have made significant improvements.

However, one issue that still persists is the nature of JavaScript itself. JavaScript is a single-threaded language, meaning that JavaScript code is executed in a single thread, and true parallel execution is not…

--

--

Lin Dane

AI Engineer & Indie Hacker | AI Engineer at VulcanLabs by day, Indie Hacker by night