August 24, 2015

Best-In-Class JavaScript AJAX Library Comparison 2015

Problem Statement

Our team decided that it would be helpful to use the same ajax library on our nodejs servers as we do in the browser. Having a consistent API in both domains should lend some sanity as devs jump between worlds!

Process

I knew going into this that there are many JS AJAX libraries available. I didn't realize how many there are. Hundreds. To whittle down the list, I decided that competing libs must:

  1. work x-env
  2. be modern (update in 2015)
  3. be in the npm ecosystem, unless a great option exists elsewhere
  4. have a sensible payload
  5. have a promise API, vs. node-callback style. we want support for async-await / yield syntax
  6. the package shall be tested

csv version of table @bottom of post

Conclusion

I am a fan of axios, at current time. It comes with all the fixins at a reasonable file size. Give it a whirl!

// csv
// sizes not listed for non-browserified packages
package,browser,node,promise,size (minified)  
jquery,yes,yes,"kinda *grumble*",84kb  
request,no,yes,no,?  
browser-request,yes,yes,"no-thenify incompatible",9.1k  
xhr,yes,yes,no,6.5k  
axios,yes,yes,yes,31kb  
xhr-promise,yes,yes,yes,113kb  
unirest,no,yes,yes,?  
ajax / component-ajax (ForbeLindesay),yes,yes,no,7.8k  
superagent,yes,yes,no,12k  
superagent-promise,yes,yes,yes,14k  
  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket
Comments powered by Disqus