4 ms·
You had me convinced until I scrolled down to read the code examples and realized why I actually do need jQuery. If its between adding yet another collection o
by phaed 13y ago
You had me convinced until I scrolled down to read the code examples and realized why I actually do need jQuery. If its between adding yet another collection of utility functions to approximate the functionality jQuery would give me vs just adding jQuery. I'd rather go with jQuery.
- sfeng 13y agoOne way of looking at it is that if you already have underscore to give you _.extend and the like, you can get pretty far with just what the browser gives you.
- VMG 13y agoThe first example alone is reason enough to use jQuery - why would I want to use four statements instead one? Why would I want to have to remember to call `send`? Why do I have to remember the last boolean parameter of `open`?
- sfeng 13y agoTotally valid, but just to say, jQuery's API is just as arbitrary, you just happen to know it better. If you use the native XHR a couple times, you know what open's parameters are.
- alxndr 13y agoIt is just as arbitrary, but I feel jQuery's API is also easier to grok at a glance. Using either a couple times may instill the parameters in your memory, but what about coming back to it after six months?
- ufo 13y agoIf you are writing a library, eliminating a dependency is worth much more then 4 lines of code. But yeah, if you are just writing code for your own site then knock yourself out.
- vinceguidry 13y agoWhich javascript library are you developing?
- flomo 13y agoI had exactly such a collection of DOM utility functions and was glad to give it up. For example, rooting around in element.className was never very enjoyable. Also, the site does not show handling null cases which adds more code.
- nostrademons 13y agoYou have element.classList on all modern browsers now: http://caniuse.com/#search=classList http://caniuse.com/#search=classList It used to be that the first thing I'd reach for when building a prototype was JQuery off a CDN, but now I find that more and more of what I use JQuery for is built into the browser, and in my last few prototypes I've just stopped including it at all because I don't need it.
- nswanberg 13y agoDid anyone ever take you up on your hackathon idea? https://news.ycombinator.com/item?id=6645426 https://news.ycombinator.com/item?id=6645426
- nostrademons 13y agoNope, I didn't hear anything further on it. Still seems like an interesting event to me, though finding time might be hard. (FWIW, we do similar things within my employer all the time.)
- nswanberg 13y agoThat's too bad. But as with all things it takes time and organization in addition to some willing victims. "Similar things" as in hackathons for fun, or hackathons structured to test out different approaches and tech?
- nostrademons 13y agoHackathons (really, prototypes) structured to test out different approaches.
- __david__ 13y agoI think the question is, does your library need every function on that page? If so, just use jQuery. But do you just need one thing? Then maybe it's better to just make the one utility function rather than pull in all of jQuery.