Starter layouts load Google Fonts with display=swap and shift text after first paint

Open
#723 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
playwright, react

Research direction

Start with nexy/modules/cli/templates/_shared/web-ui/src/routes/layout.nexy.jinja2:17, then inspect the adjacent framework-specific starter layouts and matching layouts under examples/. Locate the existing Playwright test and extend it to delay the fonts.googleapis.com response while recording CLS. The change is done when display=optional appears in every framework root layout and the delayed-response test records CLS 0.000.

Written by the indexing model from the issue text.

Description

Problem

The starter layouts link Google Fonts with display=swap, for example
nexy/modules/cli/templates/_shared/web-ui/src/routes/layout.nexy.jinja2:17 and the React, Vue,
Svelte, Solid and Preact variants beside it. The fallback font paints first, then the web font
replaces it and moves the text.

The baseline from #713 records CLS 0.000 on a cold page. It does not wait for the font response,
so the shift is not covered by any measured scenario.

Change to make

Measure the shift with a delayed fonts.googleapis.com response, then switch the starter layouts
to display=optional so a font that is not ready at first paint is skipped for that load. Apply
the same change to the example layouts under examples/.

Out of scope

Self hosting the font files and changing the font families are not part of this issue.

Checks

A Playwright test with a delayed font response records CLS 0.000. A project created by nx new
carries display=optional in its root layout for every framework.

Dominant language
Python
Stars
11
Forks
6
Avg merge
2h 14m
Merged PRs (30d)
265

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NexyPy/nexy

All issues in NexyPy/nexy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.