Tag
runtime
Published articles tagged runtime.
Breaking up long tasks
A page that ignores clicks for a moment, a spinner that never appears, or a poor Interaction to Next Paint score usually has one cause: a single task holding the main thread. This page shows how to confirm it, why await alone does not help, and the three fixes — yield, defer, or move the work.
Concurrency with workers
Workers are how JavaScript runs in parallel: each one is a separate thread with its own heap and event loop, talking to the others through messages. This chapter covers starting workers in browsers and Node, what copying, transferring, and sharing memory each cost, and which kind of worker fits which job.
Execution contexts and the call stack
Every running piece of code has an execution context that says where its variables are, what this is, and which realm's built-ins it sees. This chapter follows contexts onto and off the call stack, explains hoisting, closures, suspension, and realms in those terms, and shows how to read the stack traces that come out of it.
From source code to machine code
An engine has to start running code within milliseconds and still end up with fast machine code for the functions that matter. This chapter follows a function through V8's parser, interpreter, and three compilers, shows how type feedback drives optimization, and explains why optimized code gets thrown away.
JavaScript engine glossary
The Under the Hood series uses terms from three sources: the ECMAScript specification, the HTML Standard's event loop, and the engines' own documentation. This glossary defines each of them in a sentence or two, grouped by topic, and links to the chapter that explains it.
Memory management and garbage collection
JavaScript gives you no way to free memory, only ways to stop referring to it. This chapter explains what the heap holds, how a tracing collector decides what is garbage, why V8 splits the heap into generations, how heap limits and weak references work, and why cleanup of files and sockets cannot be left to the collector.
The event loop, tasks, and microtasks
The event loop is what turns one thread into a responsive program: it picks a task, runs it to completion, drains the microtasks, and gives the browser a chance to render. This chapter walks one turn of the loop, predicts the output of ordering puzzles from first principles, and shows where Node's loop differs.
JavaScript under the hood
Your code runs inside an engine, the engine runs inside a host, and the host decides when your code runs at all. This overview maps those layers, follows one small program through all of them, and points to the chapter that takes each layer apart.