Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Performance between class and attribute selectors

I'm wondering if there is a performance issue using attribute selectors instead of class selectors.

div.test {}
div[test] {}

P.S. : I'm only interested in CSS performance, not JS.

like image 752
Tot Avatar asked Mar 09 '14 15:03

Tot


2 Answers

According to this article, class selectors are more efficient than attribute selectors.

like image 146
Anthony Atkinson Avatar answered Nov 14 '22 08:11

Anthony Atkinson


According to this project there is no real performance issue.

This surprised us, since selector performance hasn't been a real concern in our day-to-day work for a while. Front-end performance is a huge deal, of course, but CSS selectors appear to contribute such a minuscule amount to the total page load time that it didn't occur to us that it might be a major concern to many people.

They have benchmarks as well. EDIT: see comment: they have benchmark ideas*, not benchmarks.

https://github.com/amcss/am-benchmarks

like image 44
PEZO Avatar answered Nov 14 '22 09:11

PEZO