Re:Removing jQuery from GitHub.com frontend
by Ajedi32 on Wednesday July 25, 2018 @09:42PM
(#17614490)
For comparison, here's the first example, but using fetch:
fetch('/my/url').then((r) => r.json()).then((data) => {
})
And as an added bonus, fetch uses promises, so in an async function that's just: let data = await fetch('/my/url').then((r) => r.json())
Re:Removing jQuery from GitHub.com frontend
by Cthulhu_ on Thursday July 26, 2018 @05:41AM
(#17616201)
I'm not a fan of mixing await and .then myself;
let data = await (await fetch('/my/url')).json();
That's a one-liner, but you can split the request and json data as well (and you usually want to anyway because of error handling).
Re:Removing jQuery from GitHub.com frontend
by aloisdg on Thursday July 26, 2018 @02:31AM
(#17615450)
You can write `(r)` like this `r`. Remove clutter. You don't write `let i = (0)`
Further, there are many better animation libraries.
And finally if you use any view framework you have very little need to be traversing the DOM.