Live data from Hacker News

Why use jQuery when you can use Zam?

news.ycombinator.com

1–3 of 3 posts

Re: Why use jQuery when you can use Zam?

#2
Well, since you asked.

The documentation is a long way from being good enough. There's a couple of lines about what the expected parameters are and what's returned and nothing else. That's not good enough for me to bother giving the library a try. Furthermore there's no way to link to a page, so it'd be harder to discuss it with the rest of my team.

Secondly, the ajax function expects a callback instead of returning a promise. Unless you're rigorous about structuring your code that's going to end up a bit of a mess as soon as you have more than a very basic app, especially if you're chaining calls. What's slightly odd is that you'd get promises for free if you were using the fetch API (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) instead of XMLHttpRequest.

Lastly there's things in there that look like they'd be quite hard to use. For example, every time you call your addStyle method it creates a new style tag in the page header rather than creating one and reusing it. Your each function uses querySelectorAll to find things on a page and passes them to a callback, but querySelectorAll returns a static node list (https://developer.mozilla.org/en-US/docs/Web/API/NodeList) rather than an array of elements so anyone trying to modify things on a page with that is going to have problems. That's fine if that's what you want to do, but the documentation should tell the user that's what's happening.

It's not a bad start but it's not going to replace jQuery just yet.

Re: Why use jQuery when you can use Zam?

#3
post #2

Well, since you asked. The documentation is a long way from being good enough. There's a couple of lines about what the expected parameters are and what's returned and nothing else. That's not good enough for me to bother giving the library a try. Furthermore there's no way to link to a page, so it'd be harder to discuss it with the rest of my team. Secondly, the ajax function expects a callback instead of returning…

Thank you so much for your feedback!

The documentation is a work in progress.

The ajax function is a bit of a mess and needs to be reworked. Fetch is most likely the better option unless Promises are incorporated.