Skip to content

docs: show a reliable way to preload fonts#16424

Draft
Nic-Polumeyv wants to merge 2 commits into
sveltejs:version-3from
Nic-Polumeyv:docs-font-preload-anchor
Draft

docs: show a reliable way to preload fonts#16424
Nic-Polumeyv wants to merge 2 commits into
sveltejs:version-3from
Nic-Polumeyv:docs-font-preload-anchor

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Depends on #16443.

The docs say to opt fonts into preloading with a preload filter but not what to match against, so what everyone writes is a substring check against the hashed output path — svelte.dev's own hooks does this — which silently stops matching when the font is renamed.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Jul 19, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from a11f6b8:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/a11f6b8b8e3b97d617e9c623a1a44ed39fdc17e5

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16424

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a11f6b8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Nic-Polumeyv
Nic-Polumeyv force-pushed the docs-font-preload-anchor branch from 71aaa0d to 80a6abe Compare July 19, 2026 03:49
@Nic-Polumeyv
Nic-Polumeyv marked this pull request as ready for review July 19, 2026 03:51
@Nic-Polumeyv
Nic-Polumeyv marked this pull request as draft July 19, 2026 03:59
@Rich-Harris

Copy link
Copy Markdown
Member

Hmm. I wonder if we should provide a name property that represents the original basename. Only for font and asset types, since JS/CSS is bundled. We probably wouldn't even need a lookup, since assetFileNames is predictable

@Nic-Polumeyv

Nic-Polumeyv commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Agreed, that would remove both footguns this recipe works around. Deriving it from the path mostly works, though there are edge cases I found: dotted basenames like inter.var.woff2, and rolldown sanitizing characters like + to _. We might not need to derive at all though, the client manifest already has the source path for every emitted asset and it's in scope in build_server.js where the fonts arrays get written.

I think I can implement this. I'm very supportive of this. Happy to make a separate PR and fix this one for docs.

@Nic-Polumeyv
Nic-Polumeyv force-pushed the docs-font-preload-anchor branch from 24c920b to a79a518 Compare July 20, 2026 19:54
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.

2 participants