Skip to content

feat: Add preload links for the startup chain - #1100

Merged
MartinZikmund merged 15 commits into
mainfrom
dev/mazi/boot-preload-links
Oct 8, 2026
Merged

MartinZikmund merged 15 commits into
mainfrom
dev/mazi/boot-preload-links

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #1093

Stacked on #1098 (same publish targets). Retarget to main once it's merged; CI only runs for PRs into main.

What changed

The browser discovered the startup files one round-trip at a time: index.html → uno-bootstrap.js → uno-config.js → dotnet.js → the runtime modules and dotnet.native.wasm. The require.js dependencies only started once the runtime was ready.

Publishing now inserts hints before </head>, between <!-- uno-preload-links --> markers (replaced on republish):

  • modulepreload for uno-config.js, dotnet.<fp>.js and the runtime's dotnet.runtime/dotnet.native modules
  • preload as="fetch" crossorigin="anonymous" type="application/wasm" for dotnet.native.wasm. There's no integrity attribute: Chrome ignores it on fetch preloads and warns (crbug.com/981419).
  • preload as="script" for the require.js dependencies

The URLs are derived from the uno-bootstrap.js script tag in index.html, so they follow the base path. The uno-config.js hint follows where the file was published: next to index.html (the layout from #1077) or in the package_<hash> folder. They come from the boot config embedded in dotnet.js; the SDK's endpoints manifest only marks dotnet.js for preloading. Disable with WasmShellGeneratePreloadLinks=false.

Validation

  • Browser, RayTracer sample: boots with every startup URL requested once, and Chrome logs no "preloaded but not used" warning.
  • Measured with an equivalent hand-written set of hints on a Uno 7.0 template app, through a test server simulating 4G (80 ms RTT, 12 Mbps): the large downloads start at ~280 ms instead of ~620 ms. Cold startup went 9.91 → 9.51 s on 4G and 59.9 → 58.9 s on 3G (300 ms, 1.6 Mbps) (medians, n=5/3). It's a latency win; on bandwidth-bound links, bytes dominate.
  • New Test 11 in test-fingerprint.sh: the hints include the current dotnet.js, and every hint points at a published file. Tests 1–11 pass.
  • Unit tests: Given_PreloadLinks.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N5azy6DU7ujLte16VPVYQs

Copilot AI balanced review requested due to automatic review settings October 1, 2026 11:42
@MartinZikmund MartinZikmund self-assigned this Oct 1, 2026
@mergify

mergify Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Legacy runtime resource shapes and non-fingerprinted publishes are not handled correctly, and the required specification is missing.

Review effort: Balanced
Findings: 2 Medium severity · 2 Low severity

Open (4)
What changed in this PR

Adds browser preload hints to parallelize Uno WebAssembly startup downloads and reduce latency.

Changes:

  • Generates preload/modulepreload links from runtime configuration.
  • Integrates generation into publishing with an opt-out property.
  • Adds tests and deployment documentation.
File Description
test-fingerprint.sh Validates published preload URLs.
PreloadLinks.cs Builds and inserts preload markup.
GeneratePreloadLinksTask.cs Implements the publishing task.
Uno.Wasm.Bootstrap.targets Registers and invokes preload generation.
Given_PreloadLinks.cs Tests link generation and replacement.
deploy-and-publish.md Documents behavior and opt-out configuration.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Uno.Wasm.Bootstrap/PreloadLinks.cs Resolved
Comment thread doc/deploy-and-publish.md Resolved
Comment thread doc/deploy-and-publish.md Resolved
@MartinZikmund
MartinZikmund added this pull request to stack #1106 October 7, 2026 15:49
Copilot AI balanced review requested due to automatic review settings October 7, 2026 15:49
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/boot-preload-links branch from 65bb7b1 to b0cd654 Compare October 7, 2026 15:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@MartinZikmund
MartinZikmund removed this pull request from stack #1106 October 7, 2026 17:01
@MartinZikmund
MartinZikmund changed the base branch from dev/mazi/uno-config-cache-safe to dev/mazi/dotnetjs-stale-fingerprint October 7, 2026 17:01
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/boot-preload-links branch 2 times, most recently from bcc68cf to 8f61d63 Compare October 7, 2026 17:04
@MartinZikmund
MartinZikmund added this pull request to stack #1107 October 7, 2026 17:05
Copilot AI balanced review requested due to automatic review settings October 7, 2026 19:38
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/boot-preload-links branch from 8f61d63 to 117dc01 Compare October 7, 2026 19:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Base automatically changed from dev/mazi/dotnetjs-stale-fingerprint to main October 7, 2026 21:06
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/boot-preload-links branch from 117dc01 to 53c654e Compare October 7, 2026 21:06
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Copilot AI balanced review requested due to automatic review settings October 8, 2026 07:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Copilot AI balanced review requested due to automatic review settings October 8, 2026 08:24
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/boot-preload-links branch from 7f6b2ba to 316e345 Compare October 8, 2026 08:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Copilot AI balanced review requested due to automatic review settings October 8, 2026 09:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

MartinZikmund and others added 14 commits October 8, 2026 13:40
The browser discovered the startup files one round-trip at a time:
index.html, uno-bootstrap.js, uno-config.js, dotnet.js, then the runtime
modules and dotnet.native.wasm, and the require.js dependencies only once
the runtime was ready. Publishing now adds modulepreload/preload hints for
them to index.html, matching the requests they stand for so nothing is
downloaded twice. On a simulated 4G link, the large downloads start at
280 ms instead of 620 ms; on 3G, startup is about 1 s faster.

Can be disabled with WasmShellGeneratePreloadLinks=false.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N5azy6DU7ujLte16VPVYQs
The config is versioned no more, and moves next to index.html with #1077.
Preload it from there when it is, otherwise from the package folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013terw2KRvw8e64cogQymUL
A malformed boot config or uno_dependencies array threw from the task and
failed the publish. Each section now only loses its own hints. Also checks
the dotnet.js fingerprint is a plain file name before combining paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ADrzrqtw3RQdHan77rypBM
A dictionary entry whose value carries a name points at that file, not at
its key, matching the service worker and the bootstrapper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ADrzrqtw3RQdHan77rypBM
Copilot AI balanced review requested due to automatic review settings October 8, 2026 11:40
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/boot-preload-links branch from 1e56b61 to a5e5e2d Compare October 8, 2026 11:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Copilot AI balanced review requested due to automatic review settings October 8, 2026 15:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

@MartinZikmund
MartinZikmund merged commit 66042d6 into main Oct 8, 2026
17 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/boot-preload-links branch October 8, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Startup files are discovered one round-trip at a time

4 participants