What are macro and micro tasks?

Microtasks are executed immediately after the code that started them is completed. And the macro tasks will be executed once the browser has finished all the tasks previously queued.

What are macro and micro tasks?

Microtasks are executed immediately after the code that started them is completed. And the macro tasks will be executed once the browser has finished all the tasks previously queued. To execute JavaScript code, the execution engine maintains a set of agents on which to execute the JavaScript code. Each agent is composed of a set of execution contexts, the stack of execution contexts, a main sub-process, a set of additional sub-processes that can be created to manage workers, a task queue and a microtask queue.

In addition to the main thread that some browsers share between several agents, each component of an agent is unique to that agent. The microtask queue has higher priority, so the macro task will wait for all the microtasks to be executed first.