Skip to content

selector-observer <style> rules pile up on every soft navigation, slowing typing on PR pages #10311

Description

@jakeonrails

Description

Each time GitHub soft-navigates between PR tabs (Conversation ↔ Files changed), Refined GitHub injects another full set of selector-observer <style> elements (:where(…):not(.rgh-seen-…) { animation: 1ms rgh-selector-observer }). The old ones are never removed. In a tab you keep open, the count grows without limit, and every style recalculation has to match all of them against the whole page.

On a large PR's Files changed view, that shows up as typing lag in comment boxes. Each keystroke triggers a style recalculation, so each one gets slower the longer the tab has been open. A reload fixes it until the next round of navigations.

Measured on the URL below (counting <style> elements containing rgh-selector-observer, and timing a forced style recalc after toggling a class on <body>, median of 7):

State rgh <style> count Style recalc
Fresh load of Files changed 52 46 ms
After 1 round trip (Conversation → Files changed) 183
After 3 round trips 362
After 10 round trips 992 232 ms

Each navigation adds about 45 elements. In an ordinary working tab I'd had open for about 40 minutes, there were 162 rgh styles but only 72 distinct ones (one rule had 6 copies). Disabling just the duplicates cut the worst keystroke from 160 ms to 72 ms.

How to replicate the issue + URL

  1. Open https://github.com/crmne/spotifast/pull/961/changes
  2. In the console: document.querySelectorAll('style').length, or more specifically [...document.querySelectorAll('style')].filter(s => s.textContent.includes('rgh-selector-observer')).length
  3. Click the Conversation tab, then the Files changed tab (soft navigation, no reload).
  4. Run the count again. It grows by about 45 per navigation and never drops.
  5. Repeat a few times, then type in an inline comment box: input gets visibly laggier.

I'd guess the observer's <style> isn't tied to the feature's abort signal on navigation, or the dedupe key changes between navigations, but I haven't confirmed that in the source.

Extension version

26.10.20

Browser(s) used

Chrome 155.0.8059.85, macOS

Token ⚠️

  • I set a token in the options page. I understand that some features require a token to work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions