Skip to content Skip to sidebar Skip to footer

Why Does The Promise Object Block Rendering?

I was testing the Promise object and wrote some code that simulates a long running task that is synchronous. I was comparing Promise and setTimeout - see fiddle:

Solution 1:

while (Date.now() - nu < 1000) {} doesn't simulate a long running task that is syncronous. It is a long running task that is syncronous.

Promises are a way to manage asynchronous code, not a way to make code asynchronous, nor a way to simulate multithreading.

For that, you need to look at workers.

Post a Comment for "Why Does The Promise Object Block Rendering?"