Sobes.tech
Middle

What goes into the microtask queue? Name browser Observer APIs besides MutationObserver.

sobes.tech AI

Answer from AI

Microtask queue (microtask queue) contains tasks that should be executed immediately after the current script, but before rendering and macrotask processing. These include:

  • Promises (Promise) — their handlers .then, .catch, .finally are placed in the microtask queue.
  • queueMicrotask handlers.
  • Some APIs, such as MutationObserver.

Besides MutationObserver, browsers have other Observer APIs that work on a similar principle:

  • IntersectionObserver — monitors the intersection of an element with the viewport.
  • ResizeObserver — monitors changes in element sizes.
  • PerformanceObserver — observes performance events.

These APIs allow reacting to changes asynchronously, often using microtasks to invoke callbacks.

What goes into the microtask queue? Name browser… - sobes.tech