News for hackers. Stuff that matters.
Re:I loved jQuery, and still do (2019) by acabal on Tuesday June 29, 2021 @02:43PM (#27680014)
The question should be the other way around: Why is there `getElementsByClassName` when you can do `querySelectorAll('.myClass')`? Why have `getElementById` when we have `querySelectorAll('#myId')`? Why have `getElementsByTagName` when we have `querySelectorAll('tagName')`?
Re:I loved jQuery, and still do (2019) by spiralx on Tuesday June 29, 2021 @02:48PM (#27680086)
Apart from the historical reasons both `getElementsByClassName` and especially `getElementById` are optimised - the latter being a simple lookup - which I'm not sure `querySelectorAll` is able to take advantage of.
Re:I loved jQuery, and still do (2019) by setr on Tuesday June 29, 2021 @04:18PM (#27681188)
You’d pay the cost of parsing every time, but otherwise I’d expect SelectorAll to directly depend on getElementBy.. as relevant