Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does CSS class name length affect browser performance?

Example: Gmail.

From all the DOM elements, ~2000 have at least one CSS class and there are a total of ~500 distinct CSS class names on the page. Gmail uses closure-stylesheets to minify/uglify their CSS class names. Does this step increase performance in the browser. I'm thinking about parsing/evaluating the HTML/CSS code, selector-matching, etc.

Example of uglified class name: "aBc"
Example of original class name: "tooblar__button--disabled"

like image 219
Šime Vidas Avatar asked May 06 '14 14:05

Šime Vidas


People also ask

Do CSS class names affect SEO?

CSS classes don't affect SEO and won't do it in the foreseeable future. And there's a reason for that: sites that don't use semantic class names have never been penalized for that and changing that would have a huge impact.

Does class name matter in CSS?

No, it does not.

Does CSS affect performance?

When your browser encounters CSS it stops rendering the page, parses the CSS, and builds the CSSOM (CSS Object Model). So even if you minify, compress, and merge your CSS files, an excessive amount of CSS could still slow down your website.

Which CSS selector is faster?

popupbutton is the fastest.


2 Answers

Yes. Fewer bytes is fewer bytes. The chances of it being a significant factor are tiny though.

like image 196
Quentin Avatar answered Nov 15 '22 05:11

Quentin


This doesn't affect browser performance as much as it does loading times. There is a measurable difference in rendering time, but that is only measurable when there is a significant length difference, and even then it is a tiny difference. Just look at this JSPerf which runs a test for both class name lengths. The long names have a slight disadvantage in performance speed. This could make a difference when modifying styles a huge amount of times, but on normal sites, the difference is too small to ever be noticed.

like image 29
Joeytje50 Avatar answered Nov 15 '22 06:11

Joeytje50