RESOLVED DUPLICATE of bug 297591298744
Poor performance of [class] attribute selector
https://bugs.webkit.org/show_bug.cgi?id=298744
Summary Poor performance of [class] attribute selector
Victor Lin
Reported 2025-09-11 15:30:27 PDT
Safari has poor performance on a stylesheet with thousands of [class] selectors. Demo: https://jsfiddle.net/8mturha4/2/ (click the button; color changes in chrome, browser freezes in safari) Profiling showed that the slowdown was in style invalidation (https://github.com/WebKit/WebKit/blob/ed9dd0741be2f62a9c946cc4908a013ec3db2335/Source/WebCore/style/AttributeChangeInvalidation.cpp#L72) and this makeJoining call as the hotspot: https://github.com/WebKit/WebKit/blob/ed9dd0741be2f62a9c946cc4908a013ec3db2335/Source/WebCore/style/StyleScopeRuleSets.cpp#L346 We were using `[class]` as a way of boosting style precedence without having to repeat classnames. Perhaps the attribute invalidation selector logic could be optimized when a rule is purely testing the presence of an attribute, rather than the value?
Attachments
Antti Koivisto
Comment 1 2025-09-12 00:04:35 PDT
This was fixed in https://commits.webkit.org/299018@main *** This bug has been marked as a duplicate of bug 297591 ***
Note You need to log in before you can comment on or make changes to this bug.