I think the title is explanatory. I’m becoming performance obsessed due to previous problems and am trying to get everything to max speed. As I found out that $(‘#parent’).find(‘li’) is faster than $(‘#parent li’) I feel like I don’t know anything anymore… So thus my question:
What’s faster
$('#parent .childclass1, #parent .childclass2').css(something)
or
$('#parent').children().css(something)?
Thank you in advance
The second, as it’s only doing one extremely fast dom query, then just referencing a NodeList. As opposed to doing two
document.getElementByIdcalls then checking all the children if they have a class. The second will be much faster. The first is about 60% slower then the second.