Is there a faster way to yield to Javascript event loop than setTimeout(0)?
Yes, the message queue will have higher importance than timeouts one, and will thus fire at higher frequency. You can bind to that queue quite easily with the MessageChannel API: let i = 0; let j = 0; const channel = new MessageChannel(); channel.port1.onmessage = messageLoop; function messageLoop() { i++; // loop channel.port2.postMessage(“”); } function … Read more