Comment Comment by mark242 The sizzle library that jQuery uses takes advantage of querySelectorAll.https://github.com/jquery/jquery/blob/2d4f53416e5f74fa98e0c1......only with a ton of wrapper code around it in order to support IE9 and below. If you don't have to support ancient browsers, there's no reason you can't write QSA code.var nodes = document.querySelectorAll("li"); for(var i=0; i<nodes.length; i++) { nodes[i].classList.add("foo"); }Yes it's slightly more code. It's also going to run a hell of a lot faster on, eg, a mobile device. parent mark242 9 years ago
https://github.com/jquery/jquery/blob/2d4f53416e5f74fa98e0c1...
...only with a ton of wrapper code around it in order to support IE9 and below. If you don't have to support ancient browsers, there's no reason you can't write QSA code.
var nodes = document.querySelectorAll("li"); for(var i=0; i<nodes.length; i++) { nodes[i].classList.add("foo"); }
Yes it's slightly more code. It's also going to run a hell of a lot faster on, eg, a mobile device.