Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: being able to add fonts to the head of a page so we can prevent FOUT #323

Open
pfeodrippe opened this issue Dec 8, 2022 · 4 comments
Assignees

Comments

@pfeodrippe
Copy link
Contributor

When opening https://clerk.vision/ in Chrome (didn't try it in other browsers), we have some FOUT happening as the font loading takes some time.

One way of trying to solve this (which I've tested locally and it worked for Chrome at least) would be to add fonts to the head of the page at nextjournal.clerk.view/->html (and also for the static app). We could pass options through the call to main or some other function that keeps an atom with the options we want to be used, let me know what you think o/

@mk
Copy link
Member

mk commented Feb 8, 2023

This would indeed be handy. Sketched a PoC in 7219298.

I think we'd want to support both a global and a per-notebook setting. What's a bit annoying is that the head isn't rendered by react so folks would need to reload the page to make this work but maybe that's fine as a start?

@pfeodrippe
Copy link
Contributor Author

This would indeed be handy. Sketched a PoC in 7219298.

I think we'd want to support both a global and a per-notebook setting. What's a bit annoying is that the head isn't rendered by react so folks would need to reload the page to make this work but maybe that's fine as a start?

Awesome, thanks! It seems perfect

@mk
Copy link
Member

mk commented Mar 7, 2023

With https://clerk.vision we went with an approach using alter-var-root instead, see nextjournal/clerk-website@e451a04.

Since this gives you maximum flexibility (append, prepend, modify) I'm wondering if we should make this the recommended way instead.

@elken
Copy link

elken commented Aug 18, 2023

I've tried the above here which works perfectly with the caveat that the styles are injected twice (the ID is only there so I could quickly verify this issue)

image
image

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

No branches or pull requests

4 participants