JSFoo 2012

It’s like kung fu with JavaScript and objects! All about building full size apps in JavaScript.

Yuvi Panda


Escape from Callback Hell with Deferreds

Submitted Aug 19, 2012

  • To explain fundamentals of deferreds, using jQuery’s implementation for demonstration
  • Show how hard-to-understand callback based code can be converted to clearer Deferreds based code


Tired of writing JS with so many nested callbacks that it looks like the Gaza Pyramid turned sideways? Thought you’ll never have to write synchronization code again but suddenly find yourself wanting to wait on 5 callbacks to return before you want to execute something? Hate having to add ugly boilerplate everywhere if you ever want to chain callbacks? Miss the return statement? Think your code looks ugly because it has way too many levels of indentation?

Start using Deferreds and fix all these! Deferreds are a way of managing callbacks that is painless, elegant and powerful. Using deferreds makes your code cleaner, easier to understand and less error prone. And free ponies too!


Intermediate level of Javascript knowledge would be sufficient.

Speaker bio

Yuvi Panda is a 21 year old open source geek who chases shiny new things way too often. He wrote major parts of the Wikipedia Android/iOS app (JS/Phonegap), and the upcoming Wiki Loves Monument app (also JS/PhoneGap). He was yearning for a threaded model in Javascript until he found Deferreds. Amongst his hobbies is screaming ‘USE DEFERREDS!’ at anyone claiming to use Javascript. He’s currently a student at KCG College of Technology.


{{ gettext('Login to leave a comment') }}

{{ gettext('Post a comment…') }}
{{ gettext('New comment') }}
{{ formTitle }}

{{ errorMsg }}

{{ gettext('No comments posted yet') }}

Hosted by

JSFoo is a forum for discussing UI engineering; fullstack development; web applications engineering, performance, security and design; accessibility; and latest developments in #JavaScript. Follow JSFoo on Twitter more