JS DOM: list of non-blocking functions

By Xah Lee. Date: .

List of non-blocking functions

in js, in browser, what functions are non-blocking. don't include node.js

(ai answer)

In browser JavaScript, non-blocking means async operations that don't freeze the main thread (they hand work to the browser/event loop and return immediately). Synchronous code (loops, heavy calculations, most array methods, JSON.parse, DOM reads/writes, etc.) does block.

Main categories of non-blocking APIs

Quick rules of thumb

Example of non-blocking:

setTimeout(() => console.log("later"), 0);  // doesn't block
fetch("/api").then(r => r.json());          // doesn't block

Example of blocking:

for (let i = 0; i < 1e9; i++) {}  // freezes the UI

That's the core picture for browser JS (no Node).