René's URL Explorer Experiment


Title: Proposal: `103 Early Hints` from `@angular/ssr/node`, with measurements · Issue #33819 · angular/angular-cli · GitHub

Open Graph Title: Proposal: `103 Early Hints` from `@angular/ssr/node`, with measurements · Issue #33819 · angular/angular-cli

X Title: Proposal: `103 Early Hints` from `@angular/ssr/node`, with measurements · Issue #33819 · angular/angular-cli

Description: Command build Description In #26484, @alan-agius4 wrote: Early Hints are something we want to explore further. However, we need to be cautious about adding Early Hints as similar to modulepreload links they can negatively impact performa...

Open Graph Description: Command build Description In #26484, @alan-agius4 wrote: Early Hints are something we want to explore further. However, we need to be cautious about adding Early Hints as similar to modulepreload l...

X Description: Command build Description In #26484, @alan-agius4 wrote: Early Hints are something we want to explore further. However, we need to be cautious about adding Early Hints as similar to modulepreload l...

Opengraph URL: https://github.com/angular/angular-cli/issues/33819

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: `103 Early Hints` from `@angular/ssr/node`, with measurements","articleBody":"### Command\n\nbuild\n\n### Description\n\nIn https://github.com/angular/angular-cli/issues/26484, @alan-agius4 wrote:\n\n> Early Hints are something we want to explore further. However, we need to be cautious about adding Early Hints as similar to modulepreload links they can negatively impact performance.\n> \n> For example, in the case of SSR, we may prefer prioritizing the download of images over JavaScript to avoid conflicts that could impact Core Web Vitals.\n\nThe next comment asked whether any experiments had been done, and the thread was auto-locked before anyone answered. \nI ran that experiment. This issue is the result, and a proposal to contribute the implementation, which is written and passing its own tests.\n\n**The problem.** During SSR the browser is idle. It has asked for a document, and it will not learn that the page needs `main-*.js` until the document arrives, which is after the server has finished rendering. The render time is therefore added to the time to hydration rather than overlapping it.\n\n**The measurement.** An Angular 22 application, server-side rendered, over HTTP/2, driven by headless Chrome through the DevTools Protocol. 226 KB bundle, 35 KB document, server paced to about 1.6 Mbps. The number is time to hydration, taken server-side: the app asks the server for an endpoint from `afterNextRender`, so that request cannot arrive before Angular has hydrated. Seven alternating rounds per arm, medians:\n\n| server render time | hydrated, with hints | hydrated, without | sooner by |\n| :----------------- | -------------------: | ----------------: | --------: |\n| 50 ms              |             1451 ms  |          1692 ms  |   241 ms  |\n| 300 ms             |             1466 ms  |          1941 ms  |   475 ms  |\n| 800 ms             |             1464 ms  |          2458 ms  |   994 ms  |\n\nThe shape is the finding, more than any single number. **With Early Hints the hydration time does not move**: \nit stays around 1460 ms whatever the server spends rendering, because the bundle downloads while the render happens. \nWithout them the two are serial. Early Hints make the render time free, up to what it costs to fetch the assets, so an application that renders in 20 ms gains almost nothing and one that renders in 800 ms gets nearly all of it back.\n\nTwo results worth stating because they bound the claim:\n\n- **No double fetches**, zero across every round in both arms. Every preload was reused. \n  The `crossorigin` on the module script is what makes that true: \n  a module is fetched in CORS mode, and without it the browser cannot match the preload to the fetch.\n- **First Contentful Paint does not move** (2688 ms in both arms). It should not. \n  The page is server-rendered with critical CSS inlined, so the paint never waited for the bundle. \n  This moves hydration, not paint, and I would not want the feature sold as anything else.\n\n**On the concern in #26484.** The measurement does not dismiss it. \nThis application had no LCP image competing for the bandwidth, so I cannot claim the question is settled, which is why the proposal below is opt-in rather than a default.\n\n### Describe the solution you'd like\n\nA method on `AngularNodeAppEngine`, called before `handle()`:\n\n```ts\napp.use((req, res, next) => {\n  angularApp.writeEarlyHints(req, res).catch(() => {});\n  angularApp\n    .handle(req)\n    .then((response) => (response ? writeResponseToNodeResponse(response, res) : next()))\n    .catch(next);\n});\n```\n\nIt writes nothing and returns `false` over HTTP/1.1, once the response has started, or when the document declares nothing worth announcing.\n\nThe links come from the rendered document itself, parsed once per process and memoised. \nNothing is invented: the same resources the document declares, announced earlier. \nTwo deliberate restrictions:\n- Only `preconnect` and `preload` are emitted. Browsers ignore `modulepreload` in a `103`, so a module script is announced as `rel=preload; as=script; crossorigin`.\n- A stylesheet the critical-CSS inliner has deferred (`media=\"print\"`) is skipped: it is off the critical path on purpose, and pulling it forward would compete with what is on it.\n\n**HTTP/2 only.** Browsers only act on a `103` over HTTP/2 and HTTP/3, and an informational response on an HTTP/1.1 connection can confuse intermediaries that do not expect one. \nThe node adapter already types `Http2ServerRequest` and `Http2ServerResponse` throughout, and `writeResponseToNodeResponse` already distinguishes the two by the presence of `stream`, which is the same test used here.\n\nThis is the implementation I tried (it also can works for the user without requiring any modifications to the framework.). \n\nearly-hints.ts\n```ts\n/**\n * Matches the `\u003clink>` elements of the document, so their `rel` and `href` can be read.\n */\nconst LINK_ELEMENT_RE = /\u003clink\\b[^>]*>/g;\n\n/**\n * Matches the `\u003cscript>` elements that load an external file.\n */\nconst SCRIPT_ELEMENT_RE = /\u003cscript\\b([^>]*\\bsrc=(\"|')(.*?)\\2[^>]*)>/g;\n\n/**\n * Reads an attribute out of a matched start tag.\n */\nfunction attribute(tag: string, name: string): string | undefined {\n  const match = tag.match(new RegExp(`\\\\b${name}=(\"|')(.*?)\\\\1`));\n\n  return match?.[2];\n}\n\n/**\n * Resolves a document-relative href against the base href, so the value in the header does not\n * depend on the path the request happened to arrive on.\n */\nfunction resolveHref(href: string, baseHref: string): string | undefined {\n  if (/^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith('//')) {\n    // an absolute url: usable as it is, and the only kind worth a `preconnect`\n    return href;\n  }\n\n  if (href.startsWith('/')) {\n    return href;\n  }\n\n  const base = baseHref.endsWith('/') ? baseHref : `${baseHref}/`;\n\n  return `${base.startsWith('/') ? '' : '/'}${base}${href}`.replace(/\\/{2,}/g, '/');\n}\n\n/**\n * Builds the `Link` header values for a `103 Early Hints` response out of the rendered document.\n */\nexport function extractEarlyHintLinks(html: string, baseHref: string): string[] {\n  const links = new Set\u003cstring>();\n\n  for (const [tag] of html.matchAll(LINK_ELEMENT_RE)) {\n    const rel = attribute(tag, 'rel');\n    const href = attribute(tag, 'href');\n    if (!href) {\n      continue;\n    }\n\n    const resolved = resolveHref(href, baseHref);\n    if (!resolved) {\n      continue;\n    }\n\n    if (rel === 'preconnect') {\n      links.add(`\u003c${resolved}>; rel=preconnect`);\n    } else if (rel === 'stylesheet' && attribute(tag, 'media') !== 'print') {\n      links.add(`\u003c${resolved}>; rel=preload; as=style`);\n    } else if (rel === 'modulepreload') {\n      links.add(`\u003c${resolved}>; rel=preload; as=script; crossorigin`);\n    }\n  }\n\n  for (const [, attributes, , src] of html.matchAll(SCRIPT_ELEMENT_RE)) {\n    const resolved = resolveHref(src, baseHref);\n    if (!resolved) {\n      continue;\n    }\n\n    const isModule = attribute(attributes, 'type') === 'module';\n    links.add(`\u003c${resolved}>; rel=preload; as=script${isModule ? '; crossorigin' : ''}`);\n  }\n\n  return [...links];\n}\n```\napp-engine.ts\n```ts\nexport class AngularAppEngine {\n  // ....\n  async getEarlyHintLinks(request: Request): Promise\u003creadonly string[]> {\n    const serverApp = await this.getAngularServerAppForRequest(request);\n\n    return serverApp ? serverApp.getEarlyHintLinks() : [];\n  }\n```\napp.ts\n```ts\nasync handle(request: Request, requestContext?: unknown): Promise\u003cResponse | null> {\n  // ....\n  getEarlyHintLinks(): Promise\u003creadonly string[]> {\n    this.earlyHintLinks ??= this.assets\n      .getIndexServerHtml()\n      .text()\n      .then((html) => extractEarlyHintLinks(html, this.manifest.baseHref));\n\n    return this.earlyHintLinks;\n  }\n```\n\nnode/src/app-engine.ts\n```ts\n  async writeEarlyHints(\n    request: IncomingMessage | Http2ServerRequest | Request,\n    response: ServerResponse | Http2ServerResponse,\n  ): Promise\u003cboolean> {\n    // HTTP/2 only: `stream` is what distinguishes an `Http2ServerResponse`, and it is also what\n    // `writeResponseToNodeResponse` uses to tell the two apart.\n    if (!('stream' in response)) {\n      return false;\n    }\n\n    if (response.headersSent || response.writableEnded || response.destroyed) {\n      return false;\n    }\n\n    const webRequest =\n      request instanceof Request\n        ? request\n        : createWebRequestFromNodeRequest(request, this.trustProxyHeaders);\n\n    const link = await this.angularAppEngine.getEarlyHintLinks(webRequest);\n    if (link.length === 0 || response.headersSent || response.writableEnded) {\n      return false;\n    }\n\n    response.writeEarlyHints({ link: link as string[] });\n\n    return true;\n  }\n```\n\n### Describe alternatives you've considered\n\n- **`\u003clink rel=\"modulepreload\">` in the document**, which the CLI already emits. \n  It helps, but it is discovered only when the document arrives, so it cannot use the render window at all. \n  It is what the \"without\" column above already has.\n- **A CDN generating the hints from the `Link` header**, which is what Cloudflare does and what @naveedahmed1 suggested in #26484. It works, but it requires that CDN, and it can only announce what the origin puts in a header, so the origin has to build the list anyway.\n- **Doing it in application code.** It is possible today: read the index, build the header, call `response.writeEarlyHints`. That is roughly what I did to measure it. \n  It means every application re-deriving the asset list from Angular's own output, which is the sort of thing that breaks quietly on a build change.","author":{"url":"https://github.com/nigrosimone","@type":"Person","name":"nigrosimone"},"datePublished":"2026-08-08T10:48:31Z","url":"https://github.com/angular/angular-cli/issues/33819"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0bcc92ec-c1fa-3ce0-1f63-dd6639f35bf5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9B16:1C94F:26D7695:31CA8C8:6B01DE84
html-safe-nonce78f48c632a8d2217bfe1db020125ee67777227ece4f2967f6f526d2d6901eb53
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjE2OjFDOTRGOjI2RDc2OTU6MzFDQThDODo2QjAxREU4NCIsInZpc2l0b3JfaWQiOiIxNDM5MDcxNzk1NTMyNjUyMTY0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac5fd83e352ae9ba62304f8acc406f48f8f424494a4b2a2e3ed5d7f40cba027835
hovercard-subject-tagissue:5097161638
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/33819/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d7bcf6d2a3af281500f4a1dfa0fa4bd068879642478f032c72369d6cff045699/angular/angular-cli/issues/33819
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d7bcf6d2a3af281500f4a1dfa0fa4bd068879642478f032c72369d6cff045699/angular/angular-cli/issues/33819
og:image:altCommand build Description In #26484, @alan-agius4 wrote: Early Hints are something we want to explore further. However, we need to be cautious about adding Early Hints as similar to modulepreload l...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenigrosimone
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/33819#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F33819
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F33819
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/33819
Reloadhttps://github.com/angular/angular-cli/issues/33819
Reloadhttps://github.com/angular/angular-cli/issues/33819
angularhttps://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Codehttps://github.com/angular/angular-cli
Issues198 (198)https://github.com/angular/angular-cli/issues
Pull requests23 (23)https://github.com/angular/angular-cli/pulls
Actionshttps://github.com/angular/angular-cli/actions
Security and quality8 (8)https://github.com/angular/angular-cli/security
Insightshttps://github.com/angular/angular-cli/insights
https://github.com/angular/angular-cli
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33819
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33819
Enhancementhttps://github.com/angular/angular-cli/issues?q=type:"Enhancement"
Proposal: 103 Early Hints from @angular/ssr/node, with measurementshttps://github.com/angular/angular-cli/issues/33819#top
area: @angular/ssrhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fssr%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
severity4: memory/performancehttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22severity4%3A%20memory%2Fperformance%22
needsTriagehttps://github.com/angular/angular-cli/milestone/11
https://github.com/nigrosimone
nigrosimonehttps://github.com/nigrosimone
on Aug 8, 2026https://github.com/angular/angular-cli/issues/33819#issue-5097161638
#26484https://github.com/angular/angular-cli/issues/26484
@alan-agius4https://github.com/alan-agius4
#26484https://github.com/angular/angular-cli/issues/26484
@naveedahmed1https://github.com/naveedahmed1
Preload all js bundles required for a specific route #26484https://github.com/angular/angular-cli/issues/26484
angular-robothttps://github.com/apps/angular-robot
area: @angular/ssrhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fssr%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
on Aug 8, 2026https://github.com/angular/angular-cli/issues/33819#event-29156750393
angular-robothttps://github.com/apps/angular-robot
needsTriagehttps://github.com/angular/angular-cli/milestone/11
on Aug 8, 2026https://github.com/angular/angular-cli/issues/33819#event-29156750954
alan-agius4https://github.com/alan-agius4
on Aug 10, 2026https://github.com/angular/angular-cli/issues/33819#event-29206924561
alan-agius4https://github.com/alan-agius4
Enhancementhttps://github.com/angular/angular-cli/issues?q=type:"Enhancement"
on Aug 10, 2026https://github.com/angular/angular-cli/issues/33819#event-29206926873
alan-agius4https://github.com/alan-agius4
severity4: memory/performancehttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22severity4%3A%20memory%2Fperformance%22
on Aug 10, 2026https://github.com/angular/angular-cli/issues/33819#event-29206959133
https://github.com/alan-agius4
alan-agius4https://github.com/alan-agius4
on Aug 10, 2026https://github.com/angular/angular-cli/issues/33819#issuecomment-5236919412
alan-agius4https://github.com/alan-agius4
on Oct 26, 2026https://github.com/angular/angular-cli/issues/33819#event-34255673269
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular-cli/issues/33819
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33819
area: @angular/ssrhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fssr%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
severity4: memory/performancehttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22severity4%3A%20memory%2Fperformance%22
Enhancementhttps://github.com/angular/angular-cli/issues?q=type:"Enhancement"
needsTriageNo due datehttps://github.com/angular/angular-cli/milestone/11
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.