window.setImmediate
was non-standard browser API to execute given function as soon as possible in another JavaScript context.
But Chrome removed this.
VM237:1 Uncaught ReferenceError: setImmediate is not defined
The alternative is window.queueMicrotask()
, which was defined by WHATWG as standard spec.
https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#microtask-queuing
window.queueMicrotask(() => console.log('this code runs as soon as possible!'));
Top comments (0)