You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Web: repeated scoped variable reads cause excessive style recalculations #688
Hi! I noticed a performance issue when updating ScopedVariables on web with multiple components using useCSSVariable.
I reproduced this with 100 components in the linked demo.
What’s causing it
In getWebStyles.ts, each read applies all scoped variables to a shared measurement element and removes them afterward. Consecutive reads with the same scope repeat those mutations, triggering unnecessary style recalculations.
Local fix and results
I changed this to update only values that differ and remove variables missing from the next scope, including when returning to an unscoped context.
In my app, style recalculations dropped from around **867 to 25 per update ( approximately 97% fewer ), with noticeably better responsiveness.
I’d be glad to put together a PR if this approach makes sense. Thanks!
Steps to Reproduce
Clone the reproduction repository:
git clone https://github.com/eserdeiro/uniwind-web-demo.git
cd uniwind-web-demo
Install dependencies and start the web app:
npm i
npm run web
Open the app in your browser and move the Letter spacing slider continuously.
Record the interaction in the browser’s Performance panel and inspect the repeated Recalculate Style events. The visible slowdown will vary depending on your hardware.
Activity
Brentlok commentedon Sep 24, 2026
Hey!
Sure, I'm looking forward to it, feel free to open one