Skip to content

perf(Announce): Batch getComputedStyle reads to avoid layout thrashing - #7338

Closed
mattcosta7 wants to merge 1 commit into
mainfrom
perf/announce-batched-reads
Closed

perf(Announce): Batch getComputedStyle reads to avoid layout thrashing#7338
mattcosta7 wants to merge 1 commit into
mainfrom
perf/announce-batched-reads

Conversation

@mattcosta7

@mattcosta7mattcosta7 commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Closing - No meaningful performance impact

This PR was originally created as part of the INP optimization effort (#7312), but upon review, the change has no measurable performance impact.

What the change does

// Beforeconststyle=window.getComputedStyle(element)if(style.display==='none'){return}if(style.visibility==='hidden'){return}// After const{display, visibility}=window.getComputedStyle(element)if(display==='none'||visibility==='hidden'){return}

Why it doesn't matter

Both versions call getComputedStyleexactly once. The original code was NOT calling it twice - it stored the result in a variable and read properties from it.

The only differences are:

  • Destructuring syntax (style preference, not performance)
  • One combined if instead of two (micro-optimization with no measurable impact)

Conclusion

This is a code style change, not a performance optimization. Closing to keep the PR set focused on changes with actual INP impact.

Combine display and visibility checks into a single getComputedStyle call.
Part of #7312
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9bc4202

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
@primer/reactPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Dec 15, 2025
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@mattcosta7GitHub Codespaces

Copy link
Copy Markdown
ContributorAuthor

Closing - this change has no meaningful performance impact. See updated PR description for details.

@primer
primerBot deleted the perf/announce-batched-reads branch June 30, 2026 18:10
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommendedThis change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@mattcosta7