Skip to content

legal/cookie-consent and social/share-buttons are now the top of the rules phase on script-heavy pages #270

Closed

Description

@nc9

After #1864's work on security/leaked-secrets, a11y/skip-link,
perf/js-libraries and perf/unminified-js, these two are the most expensive
per-page rules left on a ~1 MB script-heavy page. Measured on 150 copies of a
real 1.13 MB product page, medians of three interleaved runs (see
benchmarks/2026-09-perf-program.md):

rule ms/page
legal/cookie-consent 8.2
social/share-buttons 6.4

Neither was touched, for different reasons.

legal/cookie-consent spends its time in seven full-document
querySelectorAll calls with substring attribute selectors
([id*='cookie' i], [class*='consent' i], [role='dialog'], …), plus a
CMP_SELECTORS.some(sel => doc.querySelector(sel)) sweep. That is a linkedom
traversal cost, not a regex one, so the prefilter from #1864 does not apply. A
single walk collecting all seven predicates at once would be the shape of a fix.

social/share-buttons lowercases the whole page
(ctx.page.html.toLowerCase(), 1.13 MB) and then runs four /i patterns over
the copy. The i flag already makes the copy unnecessary, but removing it is
NOT a no-op: String.prototype.toLowerCase and the regex i flag disagree.
"K".toLowerCase() is "k" while /k/i does not match K, and the
same holds for İ and i. So dropping the lowercase, or dropping the i
flags, both change which pages match — on inputs nobody will ever have, but the
rule's answer would change and the change should be a decision rather than a
patch.

Acceptance Criteria

  • legal/cookie-consent costs materially less per page on the script-heavy
    fixture, with findings unchanged on the 150-page corpus
  • social/share-buttons either keeps its exact current answers or the
    divergence is decided deliberately and written down
  • the before/after numbers land as a row in benchmarks/2026-09-perf-program.md

Activity

  1. added
    enhancement
    rules
    P3
    size: M
    on Sep 23, 2026
  2. nc9 commented on Oct 7, 2026

    @nc9
    ContributorAuthor

    Triage 2026-10-07: the criteria heading is renamed to the exact ## Acceptance Criteria, and the existing list is kept as is. Suggested updates to fold in, from a read of the thread and current main:

    • legal/cookie-consent costs materially less per page on the ~1.13 MB script-heavy fixture than the measured 8.2 ms baseline, with identical findings on the 150-page corpus
    • social/share-buttons either returns exactly its current answers on the corpus, or any divergence from dropping the full-page lowercase copy (the toLowerCase vs regex i flag difference) is decided and recorded in a comment here
    • The before/after ms/page numbers for both rules land as a row in benchmarks/2026-09-perf-program.md
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

    P3enhancementrulessize: M

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions