Enjoyed an interesting video on debugging rendering performance in Chrome devtools. In his lesson, Umar identifies the CSS class change in the tag html
as the source of the rendering bottleneck. Devtools shows that changing this class potentially affects 3,874 elements in the DOM below html
and triggers an expensive operation recalculate style
.
In the past, I added CSS classes to a tag, html
or body
as a convenient way to express page state at this level.
Your CMS can do this for the same purpose. For example, on a WordPress site, you can see a bunch of type classes post-template-default single single-post postid-99999 single-format-standard logged-in category-news subcategory-uk has-hover
in the post tag body
.
Should this practice be avoided? Or will it only affect rendering performance when classes are used in CSS rules?
source
share