Skip to content

[0.44 internal alpha.4] Make the critical rendering fast path the default #1088

Description

@SisyphusZheng

Part of #1155. Target: internal alpha.4 workspace.\n\n## Context

A Lighthouse audit of the www site (mobile, Moto G + 4G throttling, production build) scored performance 84. Every deduction traced to asset discipline, not the rendering architecture — TBT ≈ 0 confirms the runtime side is clean. The findings expose a framework gap: openElement currently has no opinion on the critical rendering path. Every site must independently rediscover font preload, blocking-CSS discipline, and third-party SPOFs.

Measured evidence (prod build, getting-started):

  • CLS 0.195 (limit 0.1): four @font-face with font-display: swap and no preload → text reflows on font arrival (.article-content 0.109 + article.main 0.085).
  • LCP 2.7s (limit 2.5s): ~950ms render delay includes a render-blocking Prism theme CSS fetched from a third-party CDN origin.
  • Injected token style block ships unminified (~6 KiB avoidable).
  • dev-server Lighthouse scores are ~20 points worse than production with no tooling guidance, causing false alarms.

Proposal (candidates, each can land independently)

  1. Critical-assets convention: a declarative way to mark fonts/styles as preload/critical in openElement() config; the build emits correct <link rel='preload' as='font' crossorigin> / inline critical CSS instead of every site hand-writing headFragments.
  2. Performance-aware inject policy: the head inject already has a security allow-list (scripts rejected, base stripped); extend it to flag or reject cross-origin render-blocking stylesheets and sync external scripts, with an explicit escape hatch.
  3. Build-time minification of injected inline styles (the colorTokensStyle-style blocks).
  4. Perf gate task: a repo-task level Lighthouse/budget check against the production build (CLS ≤ 0.1, TBT budget, 'errors-in-console' = 0), plus docs guidance that performance scores are only meaningful against dist.

Non-goals

Streaming SSR does not belong here: it does not change render-blocking semantics and is a no-op for static SSG output. This issue is about static asset discipline for the prerendered path.

Site-level fixes for www land separately (font preload, self-hosted/inlined Prism, theme-init inlining). Component a11y findings tracked in the sibling issue.

Workspace boundary

Write only the alpha.4 paths assigned in tools/config/v044-alpha-workspaces.json. This issue starts with the workspace and does not wait for another Alpha workspace.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions