开发者

Performance impact of having classes with no styling?

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

E.g.:

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

where .translatabl开发者_运维百科e is used to find all the elements that are going to have their content dynamically altered in certain situations.


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.


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜