jargon

Comparison

Main threadvsWeb worker

Main thread

your loop over ten thousand rows froze the whole tab, including the scroll and the spinner.

The single thread on which the browser parses, runs your JavaScript, computes style and layout, and paints. Because all of that is serialised, any script that runs for long blocks everything else, including the animation you added to reassure the user. This is the constraint every other performance term on this page is downstream of.

Full entry →

Web worker

you moved the parsing off to another thread and the interface kept responding while it ran.

A separate thread running a script with no access to the DOM, communicating with the page by message passing. It is the only real answer to CPU-bound work in the browser, and it is under-used because the boundary is awkward: everything crossing it is structured-cloned, which for large objects can cost more than the work saved. Anything touching the DOM has to come back to the main thread, so workers suit computation, not rendering.

Full entry →

Related comparisons