Which is faster and why? Selecting div (for plugin needs) by $('div[data-something]') or $('div.something')? I lean towards the former since it’s “cleaner”.
Based on this SO question I know I shouldn’t be using both. However I didn’t find out whether there is a difference between these.
It will vary by browser. Nearly all browsers now support
querySelectorAll, and jQuery will use it when it can.querySelectorAllcan be used with attribute presence selectors, so if it’s there jQuery doesn’t have to do the work, it can offload it to the engine.For older browsers without
querySelectorAll, jQuery will obviously have to do more work, but even IE8 has it.As with most of these things, your best bet is:
Don’t worry about it until/unless you see a problem, and
If you see a problem, profile it on the browsers you intend to support and then make an informed decision.