views:

47

answers:

2

Does it impact performance to have classes that are not used for styling on elements?

E.g.:

<div class="translatable">...</div>

where .translatable is used to find all the elements that are going to have their content dynamically altered in certain situations.

+6  A: 

These classes increase the document load time (more text = more time) and have a very tiny impact on the time required to interpret any class reference (I assume class names are in hashtables and an extra name could cause such a hashtable to be allocated a little larger).

So... there will be an impact, but unless your unused classes make up a significant percentage of your CSS, it will be hard to see or measure. I can't see worrying about a single class.

Carl Smotricz
A: 

if you are using it purely for lookups later then it should be fine but if you have a large document and then start updating that specific style then you are going to hit performance issues when the browser does a reflow and repaint.

Stoyan Stefanov of Yahoo! explains it quite well on his blog http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/

AutomatedTester