3 ms·
I built a modern jQuery and it's only 4kb after gzip
- jazzypants 3y agoI used modern web API's like proxies, promises, and fetch to do things that jQuery couldn't even imagine. Some of the features: - Automatic Promise Unwrapping: You don't have to await async functions. - Automatic Error Handling which can be customized: You don't need to try/catch those promises. - Async Queue System: Every method call waits for the previous one to finish and operates on the most recent version of the proxy. - Full access to the entire DOM API if you don't want to use a custom method. - All array methods return the proxy when operating on it so you can make new queues with them. - Streaming HTML through readable streams or server-sent events. - All AJAX methods have event hooks like onWait, onSuccess, and onError - Automatic Form Serialization: You don't even need to set a URL or body! - Fully Type-Safe: If you use a tag name for the selector, it is automatic. And, it's still over nine times smaller than jQuery itself. [Here's a link to the Github Repo!](https://github.com/jazzypants1989/jessquery https://github.com/jazzypants1989/jessquery) It includes a three-hour long code walkthrough if you want to learn more about how I did all of this. To clarify, I don't know how performant this would be in a production application, but I think this stands on its own as a proof of concept.
- hapulala89 3y agoOh yeeess. This is sexy.