Skip to content

New rule: broken scripts, stylesheets and fonts (no render needed) #703

Closed

Description

@nc9

Problem

A page whose main script or stylesheet returns 404 or 500 looks fine to the crawler: the HTML is 200, the title and meta are there. In a browser the page is unstyled or its interactive parts never run. The classic cause is a deploy: cached HTML still references hashed bundles (/assets/app.3f9a1c.js, /_next/static/chunks/123.js) that the new deploy deleted.

squirrel already fetches these files. The asset phase requests every referenced script (site.scripts), stylesheet (site.resourceSizes.css) and font (site.resourceSizes.fonts), and stores status, error and sourcePages for each. The size, compression and caching rules read those entries, but no rule reports a 4xx/5xx or a failed fetch. Images are the exception: images/broken-images covers them.

Proposal

New rule reliability/broken-resources that reads the existing asset data. It needs no render, so it runs in the CLI and in HTTP-only audits.

  • Error: a first-party script or stylesheet (same registrable domain as the site) answers 4xx/5xx.
  • Warn: a third-party script or stylesheet answers 4xx/5xx, a font answers 4xx/5xx, or any of these fails at the network level (DNS, TLS, timeout).
  • Not broken: 429, 503 with Retry-After, or a WAF challenge. Report these as unverified (info), the same way link checks do.
  • One finding per resource URL, listing the status and the pages that reference it, rather than one per page.
  • Says when the check was partial: the asset fetch is capped, so the finding should say so when not every referenced resource was checked.

New category: Reliability

None of the existing categories fit: Core SEO is meta tags and page structure, Site Integrity is about compromise (cloaking, malicious scripts), and a broken bundle is a correctness problem, not a speed one. Add a Reliability category (code reliability, rule prefix reliability/):

Notes

Acceptance Criteria

  • A reliability category exists (name "Reliability", in the Performance group) and appears in reports, scoring and the docs rule index
  • Fixture: a page with <script src="/app.js"> where /app.js returns 404 produces an error finding naming the URL, the 404 status and the referencing page, in an HTTP-only (non-rendered) audit
  • Fixture: a first-party stylesheet returning 500 produces an error finding
  • Fixture: a third-party script returning 404, and a font returning 404, each produce a warning, not an error
  • A resource answering 429, 503 with Retry-After, or a WAF challenge is reported as unverified (info), never as broken
  • The same broken URL referenced from 5 pages produces one finding listing those pages, not 5 findings
  • When the asset fetch cap left referenced resources unchecked, the result says so
  • Broken images stay with images/broken-images and are not reported twice
  • The rule has a docs page under docs/rules/reliability/

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementrulessize: S

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions