Skip to content
jQuery-compatible standalone Deferred (promise) implementation
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


deferred-js is a light (less than 1 kb gzipped) standalone implementation of promise/deferred that aims to be fully compatible with $.Deferred found in [jQuery 1.5+] (

What's implemented ?

  • Deferred.always
  • Deferred.done
  • Deferred.isRejected
  • Deferred.isResolved
  • Deferred.notify
  • Deferred.notifyWith
  • Deferred.progress
  • Deferred.promise
  • Deferred.reject
  • Deferred.rejectWith
  • Deferred.resolve
  • Deferred.resolveWith
  • Deferred.state
  • Deferred.then
  • Deferred.when

What's Missing ?

  • Deferred.pipe


Using nodejs

  • type in a terminal: npm install deferred-js
  • require deferred-js: var Deferred = require('deferred-js');

Using a browser

  • include the deferred script: <script type="text/javascript" src="deferred.js"></script>
  • Deferred is available inside the global object


// Create a Deferred and return its Promise
function asyncEvent(){
	var dfd = new Deferred();
	}, Math.floor(Math.random()*1500));
	}, Math.floor(Math.random()*1500));
	return dfd.promise();

// Attach a done and fail handler for the asyncEvent
		console.log( status+', things are going well' );
		console.log( status+', you fail this time' );


This software is distributed under an MIT licence.

Copyright 2012 © Nicolas Ramz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.