node package manager


Cross platform async for JavaScript.

========= Defer.js

Cross platform async for JavaScript.

.. image:: :target: :alt: Current Build Status

What Is Defer?

Defer is a utility library that allows JavaScript developers to write async code that works across multiple JavaScript platforms.

This functionality is provided in Node.js through its process.nextTick and setImmediate functions. The ability to micromanage the JavaScript concurrency model is a major benefit of the language that this library extends to browser environments.

Developers of cross platform JavaScript libraries can use Defer as a foundation for providing async behaviour that is consistent across multiple environments.

Show Me


function logSomething() { console.log("ASYNC"); }


// Console Output: "SYNC"
// At some point later:
// Console Output: "ASYNC"

Defer exposes a function called defer. This function is an abstraction over platform specific methods for deferring the execution of a function until a later cycle of the event loop. In modern Node.js this function aliases setImmediate. In legacy Node.js process.nextTick is used. In modern browsers this function leverages window.postMessage. In legacy browsers this function falls back on setTimeout.

For more detailed usage guides and API specifications, see the docs directory.


This package is published through NPM under the name deferjs::

$ npm install deferjs

Once installed, simply defer = require("deferjs").

This module uses browserify to create a browser compatible module. The default grunt workflow for this project will generate both a full and minified browser script in a build directory which can be included as a