Search code examples
javascriptjqueryajaxzepto

jQuery like standalone ajax library


I was working on a javascript project using jQuery 2.1.0 for ajax request (among other things) and now I need to get rid of the jQuery dependency.

To keep this change as simple as possible I need to find a light-standalone library that provides an ajax abstraction layer (just ajax if it's possible) maintaining the exact same jQuery 2.1.0 ajax interface. I specially need that the request returns the same promise as jQuery would do.

I've tried jQuery custom builds and Zepto custom builds, but they are still too heavy for just having an ajax abstraction layer.


Solution

  • You can use jQLite which contains an ajax function, only weights 16k so is very light and shouldn't be a problem.

    Also once you add the script of jQLite, it checks if there is already a jQuery version, in that case doesn't override the $ global variable name

    Update

    PD: you can implement your own function for AJAX request using this code for example, and providing a simple interface of the request, method and callback/errback of the request depends of how critical is for the weight of the library, however using CDN libraries your page should'n get any slower