jQuery

jQuery Deferreds

jQuery Deferreds are a convenient way to manange asynchronous responses in Javascript. Recently, I came up against a problem where I had to handle groups of Deferreds (or rather, promises) collectively, and add more promises to those groups later in the process. To improve the readability and flexibility of the code, I wrapped the Deferreds of each group in a new kind of $.Promises object, which I'd like to introduce here.

jQuery quirky

jQuery functions provide a convenient shorthand for retrieving information from the DOM. There is no need to think about browser-specific quirks – mostly. Here is a case where it doesn't work out.

Retrieving the size of a document should be a straightforward affair: a simple $( document ).width() or $( document ).height() call, and you are done. Yet in IE, these calls often return a size just a little bit too large. Sometimes they are off by as little as 4px, sometimes the difference accounts for the width of the scroll bar, or the scrollbar plus 4px. This bug has been around for a long time. As of jQuery 1.6.1, it is still with us, and it looks like it's going to stay that way.