Use of :has() pseudo-selector hurts performance on some pages
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- css
- Domain
- performance, web-dev
Research direction
Start by reviewing the :has() selectors in shutup.css, the context in RickyRomero/shut-up-webextension#68, and the linked slow-scrolling example. Compare scrolling performance with those selectors removed, then determine and document which mitigation is accepted; completion is not defined by the issue yet.
Written by the indexing model from the issue text.
Description
See RickyRomero/shut-up-webextension#68 for more context. I removed all selectors that make use of :has() from shutup.css and it greatly improved performance on my 2018 Intel MacBook Pro when scrolling this page.
We've been making use of :has() more frequently for hiding comments on pages. This has been incredibly useful since it lets you query based on the contents of a given selector, and modern web apps are getting increasingly harder to block comments on because of the abstractions used to build them. But on web apps that make frequent modifications to the DOM, this pseudoselector causes the browser to bog down when recalculating styles.
I need to do some more investigation to see if there are any optimizations I can make that still let us use :has() in shutup.css, but wanted to file this here in case you had any ideas for dealing with this problem.
My initial thought, if we can't optimize this problem away, is to move any use of :has() into another stylesheet (shutup-heavy.css) that people can add if they want better comment blocking at the expense of performance. I don't love this idea.
Another approach could be to ban the use of :has() and require using more performant selectors instead, but this would limit our ability to block comments by quite a bit.
Or, we could require any use of :has() be scoped to a specific domain name in the browser extension. We could leave :has() in shutup.css for people who use it as a user stylesheet or with Stylus, but in the browser extension I could have a build step which scopes the selectors to specific domain names.
Just spitballing here, again, I haven't looked into whether this can be optimized around or not by writing :has() selectors differently, but wanted to see what you think.
- Dominant language
- CSS
- Stars
- 268
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from panicsteve/shutup-css
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
panicsteve/shutup-css#236 ·
All issues in panicsteve/shutup-css
Similar issues
-
area: cli area: dogs perf priority: P3
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vllm-project/vllm#57936 · 1 comment ·
-
contributor: external needs review
Difficulty 2/5 1-3 hours Newbie friendliness 82/100