Repository navigation
Conversation
…on static pages (#1143) New info rule and a shared payload analyzer: __NEXT_DATA__, the Next.js app router flight chunks, __NUXT__, Remix, Qwik, SvelteKit and Astro island state, sized per page with bounded reads. Reports only when the payload is at least 100 KB and 20 times the visible text on a page with at most 5 form controls and embeds and 50 buttons. Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
) Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
This was referenced Oct 30, 2026
Contributor
Author
|
Landed in v0.0.143 as nik |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1143.
PR1 of the G6 pair. #1200 (
perf/content-in-js-bundle) follows as a separate PR targeting main, depends on this one, and reusespackages/rules/src/shared/framework-payload.ts(bounded script reads, framework state detection).What
New page-scope info rule
perf/framework-data-payload: a page that is mostly text but carries a large inline framework payload (the same content shipped as markup and as JSON).shared/framework-payload.ts(shared analyzer):findFrameworkPayloads(doc)names and sizes__NEXT_DATA__, Next.js app routerself.__next_fflight chunks (summed),window.__NUXT__and__NUXT_DATA__,window.__remixContext,__staticRouterHydrationData, Qwikqwik/json, SvelteKit__sveltekit_,__INITIAL_STATE__/__PRELOADED_STATE__/__APOLLO_STATE__, and Astroastro-islandprops. JSON-LD, import maps and ordinary scripts are not counted.measureInteractivityandvisibleTextLengthgive the "static page" side.min_bytes), payload >= 20x visible text (min_text_ratio), form controls + embeds <= 5 (max_interactive), buttons <= 50 (max_buttons). Everything is an option.Threshold evidence (smoke run, 40 public pages)
Next.js app router pages carried 50 to 460 KB of flight data against 1 to 8 KB of text (ratios 9 to 425). Pages router and Nuxt: 21 to 250 KB. Pages with no detectable payload (Remix, Astro, TanStack, Gatsby and others) report nothing. Interactive pages sit apart and are NOT flagged: a flexbox tutorial (45 form controls, 4 embeds, 155 KB payload vs 33 KB text), a component library home (19 form controls, 435 KB), a Next.js home with 7 form controls. Marketing, docs and blog pages with 0 to 4 form controls and 120 to 460 KB payloads are the ones flagged. One page (react.dev) measured 0 visible text in the node walk, so its ratio is not trusted and I did not tune on it. Raw numbers are in the rule docs summary, not the fixtures.
Four-file recipe and counts
packages/rules/src/performance/framework-data-payload.ts,performance/index.ts.docs/rules/perf/framework-data-payload.mdx,docs/docs.jsonnav, generated hub table, perf count 30 to 31 (docs/rules/index.mdx,docs/rules/performance/index.mdx),constants.tscomment 310 to 311.PUBLIC_RULE_COUNT_FLOOR(300) is unchanged: the live total moves to 311, inside floor + 50.packages/rules/tests/framework-data-payload-1143.test.ts(14, synthetic pages shaped like the real ones: each framework, JSON-LD/importmap negative, noscript, deep marker, script cap, flagged, small, interactive, embeds, mostly-data, hidden inputs, options, no document); verdictScopepage, listed intemplate-invariance-measured.jsonvaryingRules(both corpora); canonical golden:perRuleTally314 to 315, findings +500 (103244 to 103744), health score unchanged.totalRulesliteral inapps/web/src/components/rules.tsx, and the gitlink; the private rule-count guards read the public docs literals, which this PR updates. New total: previous + 1.Verified / not
Verified: tsgo (rules),
make validate, the new test, rule-verdict-scope, template-verdict-page-independence, template-verdict-inputs, docs-category-table, meta-string-limits, docs-rule-pages, the canonical golden; a localsquirrel audit(dev entry,--offline --http) of a page with 160 KB of flight data ran the rule through the real engine (1 info check, 1 ms) and a control page passes. Not verified: the fullscripts/test-suites.ts --run rulessuite (left to CI); info checks are not shown in CLI JSON/LLM output (pub#669), so the live run was confirmed from the rule profile line, not the report.Skill: no change needed (the skill does not list individual rules).
Caps on untrusted input (scan follow-up)
The analyzer reads pages an audited site controls, and never parses or runs a pattern over a payload body. Caps: 2,000 inline scripts and 500
astro-islandelements read per page; a script is tested only on its first 160 characters (the rest is only measured by length); interactive element counts stop at 200 per kind; the text walk visits at most 200,000 nodes iteratively (no recursion, so deep nesting cannot overflow the stack);doc.bodyis read through a guard because linkedom throws on a rootless document.tests/framework-payload-adversarial-1143.test.tsfeeds a 5 MB script of brackets, quotes and escapes, a marker repeated through 5 MB, 20,000 scripts, 5,000 islands, 15,000 interactive elements, 300,000 text nodes, 3,000-deep nesting and an empty document, asserting the caps hold (counts) with a 5 s ceiling; run three times locally with no flake.Review round (g6)
min_text_chars(default 1024) the rule passes ("too little to judge"). Before, zero text gave an infinite ratio, so client-rendered shells and measurement misses could read as "mostly text" pages. Tested with empty,<div id=root>and "Loading" shells carrying 300 KB of flight data.documentBody: the other unguardeddoc.bodyreads named in review (a11y/aria-hidden-body.ts:24,content/date-agreement.ts:456,page-classifier/src/comments-rule.ts:396) read documents that come from the parser'sparseHTML. fix(parser,rules): empty-body pages and hostile ids no longer throw rule errors #1270 #1276 #1290 (open) wraps that function so a rootless document never reaches a rule, which covers all three at the root, so I did not touch those files; this PR's own guard stays as defence in depth. Rebase after fix(parser,rules): empty-body pages and hostile ids no longer throw rule errors #1270 #1276 #1290 if conflicts appear.