3 ms·
Attribute selectors have the worst performance of any selector. Coupling that with the =~ operator is even more cause for concern. This is why classes and id ex
by goldenkey 12y ago
Attribute selectors have the worst performance of any selector. Coupling that with the =~ operator is even more cause for concern. This is why classes and id exist.
- batbomb 12y agoI'm not sure, but from the post it's actually ~=. The =~ variant is used in Perl and Bash as a regex matching operator.
- ratbeard 12y agoNo, :nth-last-child(n) has the worst performance of any selector.
- bGriz 12y agospan:nth-last-of-type(2n+1):not(div) > span ? Edit: I reversed my edits to maintain proper history.
- ratbeard 12y agoYea, thats slower for sure.
- ratbeard 12y agoActually, I spoke to soon. Since selector engines work right to left, this would first narrow down the list of elements to all the spans in the document. Assuming thats a fairly small percentage of the overall tags in the document, this selector runs at .0023 ms on my MBP w/ 8 GB or RAM. Sa'll good. Edit: For the record, bGriz edited his comment, making my comment invalid. Edit (2): Thanks!
- bGriz 12y agoDefinitely fact.