NEW288923
Slow page loading with irrelevant :has() selector
https://bugs.webkit.org/show_bug.cgi?id=288923
Summary Slow page loading with irrelevant :has() selector
Jeff Johnson
Reported 2025-03-01 10:23:38 PST
Created attachment 474389 [details] Example style sheet to demonstrate the bug Safari Technology Preview 214 (Safari 18.4, WebKit 20622.1.2.111.3) and Safari 18.3 (20620.2.4.11.5) on macOS 15.3.1 Steps to reproduce: 1) Open Safari Advanced Settings 2) Select the attached style sheet in the Style sheet popup 3) Open https://news.ycombinator.com/item?id=43208973 The style sheet contains the following CSS: foobar div:has(img) button { background-color: red !important; color: red !important; } Of course the page has no foobar element, so the :has() selector should not be evaluated, but it is evaluated and slows down the page loading considerably. I think this bug is related to or the same as https://bugs.webkit.org/show_bug.cgi?id=283222 Also attached are screenshots of the web inspector Timeline: "no-style" is without using the style sheet, while "style1" and "style2" are two runs using the style sheet. You can see that the existence of the style sheet delays the first paint by several seconds.
Attachments
Example style sheet to demonstrate the bug (115 bytes, text/css)
2025-03-01 10:23 PST, Jeff Johnson
no flags
Screenshot of Timeline with no style sheet (267.35 KB, image/png)
2025-03-01 10:24 PST, Jeff Johnson
no flags
Timeline with style sheet, first run (288.54 KB, image/png)
2025-03-01 10:24 PST, Jeff Johnson
no flags
Timeline with style sheet, second run (266.25 KB, image/png)
2025-03-01 10:24 PST, Jeff Johnson
no flags
Jeff Johnson
Comment 1 2025-03-01 10:24:05 PST
Created attachment 474390 [details] Screenshot of Timeline with no style sheet
Jeff Johnson
Comment 2 2025-03-01 10:24:33 PST
Created attachment 474391 [details] Timeline with style sheet, first run
Jeff Johnson
Comment 3 2025-03-01 10:24:50 PST
Created attachment 474392 [details] Timeline with style sheet, second run
Alexey Proskuryakov
Comment 4 2025-03-03 14:46:35 PST
Thank you for the report. STP 214 includes the fix for bug 283222, so this must be a separate issue.
Radar WebKit Bug Importer
Comment 5 2025-03-08 10:24:15 PST
Note You need to log in before you can comment on or make changes to this bug.