Skip to content

scoped CSS performance impact #2608

Open
@KosRud

Description

@KosRud

- **Scoped styles do not eliminate the need for classes**. Due to the way browsers render various CSS selectors, `p { color: red }` will be many times slower when scoped (i.e. when combined with an attribute selector). If you use classes or ids instead, such as in `.example { color: red }`, then you virtually eliminate that performance hit.

After reading this part of the docs, I got curious about the performance impact of attribute selectors, but could not find any conclusive evidence one way or the other. Lots of dead links, 10+ years old articles and presentations with general advice but no benchmarks, etc. The closest thing I got was this issue, which apparently only affects IE11.

It would be great to have some context on the issue of attribute selector performance and if the mentioned performance penalty still exists today (maybe in the form of "further reading" links).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions