13

After going through several articles I have come to know that promise implementation is there in jQuery. But I am not sure whether any version of jQuery is Promise/A compliant or not.

Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504
  • No jQuery is really Promises/A complaint (which, is a poor standard in today's terms and was replaced by Promises/A+ because of it). In fact [**All jQuery promises are pretty horrible**](http://stackoverflow.com/questions/23744612/problems-inherent-to-jquery-deferred/23744774#23744774). May I recommend [**Bluebird**](https://github.com/petkaantonov/bluebird) instead? – Benjamin Gruenbaum May 30 '14 at 15:21
  • @BenjaminGruenbaum yes, i have red that Bluebird performance is better than q and when libraries. – Pulak Kanti Bhattacharyya May 31 '14 at 05:38

1 Answers1

20

Update 2015: jQuery 3.0 is Promises/A+ compatible. See this issue on GitHub so 3.0 beta is 3.0 compatible and when 3.0 is out it will also be compatible. Until then - the below still applies.

All jQuery versions (up to 3.0) feature a broken promise implementation

They don't allow error handling well, and they don't mix and match with other implementations well.

However, since version 1.8 .then exists, which means you can kind of use the jQuery implementation as promises. This is an attempt to fix this bug and become more Promises/A compliant. There is an effort to improve interoperability, which is what the promises specification is all about anyway, the target of that effort is 2.2 and 1.12.

This means that from 2.2 onward, jQuery promises will be able to interop with other promise libraries, assimilate thenables like any promise library should, and behave less incorrectly according to the spec.

For all practical uses, you should consider another implementation.

There exist a lot of good promise implementation out there. Bluebird for example is fast ( much faster than jQuery promises), has a low memory footprint, has amazing stack traces and debugging support and interops seamlessly with jQuery promises and assimilates them.

Community
  • 1
  • 1
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504
  • 1
    Benjamin from your words I have understood that 1) In a practical project, it is better to use jQuery for DOM manipulation only 2) And if there is a need for promise implementation in the same project, then one should use libraries like Bluebird in addition to jQuery. Is my understanding correct? or you would like to advice something different. – Pulak Kanti Bhattacharyya May 31 '14 at 06:53
  • @PulakKantiBhattacharyya Yes, by all means. This is exactly the stack I use. Bluebird is the best, but _most other_ implementations are still a lot better than jQuery. – Benjamin Gruenbaum May 31 '14 at 16:01
  • I am interested in learning Bluebird. Can you please share some tutorial links/examples to understand it better @Benjamin? – Pulak Kanti Bhattacharyya Jun 02 '14 at 07:45
  • 1
    @adi518 you can suggest edits - I've made the change suggested manually. Thanks – Benjamin Gruenbaum Feb 14 '17 at 14:58