4 ms·
Isn't it slower querying elements via attributes? Whenever I find a «brand» new way to work with CSS (or whatever they wanted to call it), I'm skeptical. Most
by rsoto 6y ago
Isn't it slower querying elements via attributes?
Whenever I find a «brand» new way to work with CSS (or whatever they wanted to call it), I'm skeptical. Most of the times they just redo what IDs and classes were made for, but way worse. While this might have good intentions in mind, it's just adding classes via attributes.
Also it's explained very badly, I had to click three buttons in order to get examples.
- jjcm 6y agoIt used to be. In modern engines it's really no longer the case. Just did a mini test running both attr and class name selectors on 10000 objects. In both instances the paint was fully complete in a single frame. Agree with the rest of the stuff you've said though. I just don't see a place for this library.
- dubcanada 6y agoI mean you are right, but there are certainly selectors which are "faster" just the faster part is more on the 0.000001ms level than any measurable level. Also I am fairly certain (been a while since I spent time in Webkit source) but class name and attribute selectors are implemented the same, if you want to do a proper benchmark you would want to do id, nested selectors, attributes, class, etc. And at that level you will find a significant difference.
- wilsonrocks 6y agoI could see the point in attribute selectors - when using react I find it messy to programmatically specify class names based on state/props, particularly when using BEM. Setting some Booleans as attributes is much nicer. However, it is built into CSS already, so not sure a library would help...