Skip to content

fix: cache isFireFox() result in CSSParser to avoid repeated UA scan - #1706

Open
498755303 wants to merge 2 commits into
jd-opensource:devfrom
498755303:fix/cache-isfirefox-in-scopedcss
Open

fix: cache isFireFox() result in CSSParser to avoid repeated UA scan#1706
498755303 wants to merge 2 commits into
jd-opensource:devfrom
498755303:fix/cache-isfirefox-in-scopedcss

Conversation

@498755303

Copy link
Copy Markdown

Background

recordResult() in src/sandbox/scoped_css.ts runs once per CSS fragment and
called isFireFox() every time. Parsing a single stylesheet therefore triggers
thousands of avoidable user-agent substring scans.

Change

  • Add a private field isFF, cached once at the start of exec().
  • Reuse this.isFF in recordResult() and the exec() return value.
  • Reset it in reset().

UA detection now runs once per exec() instead of once per fragment.

raoenhui and others added 2 commits June 25, 2026 18:32
recordResult() runs once per CSS fragment and called isFireFox() every
time, so a single stylesheet triggers thousands of avoidable UA substring
scans. Cache the result into this.isFF once at the start of exec(), reuse
it in recordResult() and the return value, and reset it in reset().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants