3 ms·
I started using "vanilla" js, then created a method as a name for the huge `[].prototype.slice.call(document.querySelectorAll(selector))` Then as I continued a
by franciscop 10y ago
I started using "vanilla" js, then created a method as a name for the huge `[].prototype.slice.call(document.querySelectorAll(selector))`
Then as I continued adding useful methods such as ajax() (no, in vanilla js it's not "solved") and turning events off (also non-trivial) I ended up with a jquery alternative:
> http://umbrellajs.com/ http://umbrellajs.com/
It's not exactly the same, but most methods are the same or highly compatible. For example, the append() method is extended so this does what you'd expect it to do, generate a list with first, second and third items:
u('<ul>').append(text => `<li>${text}</li>`, ['first', 'second', 'third']);
- tomchristie 10y ago> useful methods such as ajax() (no, in vanilla js it's not "solved") Right - I use jQuery because I've greater confidence that `.ajax()` will behave correctly across a wide range of browser versions, though I don't have any good evidence about using that vs vanilla `XMLHttpRequest` these days. I'd be interested to know which bits of "not solved" - which aspects in particular are not yet well supported?
- franciscop 10y agoIt's not only about criss-browser, it's about the simplicity of ajax('/api/users', function(){}, 'json'); (of course, if you want to know about compatibility, http://caniuse.com/#search=xmlhttprequest http://caniuse.com/#search=xmlhttprequest )
- woah 10y agoWhat about fetch?
- ry_ry 10y agoFetch has its own issues - not being able to abort a fetch, or recieve progress notifications are frustrating if you require them. But the deficiencies of fetch() are another topic entirely, and I tend to use it (polyfilled tbh) for the majority of my async requests because I like the rest of its implementation.