« Bugzilla Issues Index

#441 — Adding the "delay" keyword

Hi guys!

Today, a really cool idea for a new keyword in JavaScript came to my mind. It's called 'delay'.

What does the delay keyword ?

The delay keyword does nothing more than stop the execution of the current stack and immediately continues to the next task in the queue. But that's not all! Instead of discarding the stack, it adds it to the end of the queue. After all tasks before it are done, the stack continues to execute.

What is it good for?

delay could help make blocking code non-blocking while it still looks like synchronous code. A short example:





delay; //since there is currently another task in the queue, do this task first before continuing


//Outputs: one, two, three

This simple keyword would allow us to create a synchronous-looking code wich is asynchronous behind the scenes. Using node.js modules, for example, would no longer be impossible to use in the browser without trickery.

There would be so many possibilites with such a keyword!

What do YOU JAVASCRIPT DEVELOPERS think about it? What do you think can I do to bring this into the new ECMAscript Specification?

Please disuss as much as you want! :)

If you want to trigger discussion of this idea you should make a post. to

If you aren't already a member of that discussion list you can enroll at

I've already done that, thanks. I hope it will succeed :)

moved to Harmony product because this isn't a approved feature for ES6

Bulk closing all Harmony bugs. Proposals should be tracked on GitHub. The ES wiki is completely defunct at this point.