-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
fix(website): make KaTeX fonts available on alternative locales #7574
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Merging for now because en locale is returning 404 as well currently, but we should move back to CDNs. |
Size Change: 0 B Total Size: 801 kB ℹ️ View Unchanged
|
I moved those to self-hosted because I want to be able to work on Docusaurus offline or under very slow network (which I currently have at home btw), and not depend on the resilience/speed of the CDN. For sure it's possible to disable the fonts in case of need, but that seems appropriate to me to self-host. |
I'm surprised if Docusaurus CDN is more performant than jsdelivr's CDN. For me it's mainly the question of future-proofness. For example, with this change, the CSS is not resilient to site base URL changes. |
This is not a problem of CDN performance. In dev, localhost is always faster than "remotehost" (no matter what it is) Offline or with a slow network, I should be able to work locally on Docusaurus without pain (ie the first render should not be blocked by many seconds if the request is slow). Using JSDeliver, it was painful to me.
If you have any idea to make the CSS resilient or use JSDeliver, without breaking the ability to work under a very slow network, I'm fine with your solution. Maybe a better solution would be to revert this self-hosting PR #6429 |
That's what I'm asking😅 I'm not sure how gracefully it fails when that CDN asset fails to load—does the site fail to render at all? Or only the math formulae are corrupted? I don't think CSS files are render-blocking—are they? |
As far as I remember, the problem was not when it failed to load, but when the request took a very long time. I think it blocks everything on a white screen and the DX only unlocks itself after the requests timeout. Last time I had network issues, this was impossible to work under these conditions |
Mmm, I see. Let's self-host for now. At least our website isn't deployed anywhere else. |
Pre-flight checklist
Motivation
The main issue is that the stylesheet is directly linked as a
link
tag instead of getting bundled, so theurl()
functions would not have the base URL automatically prepended. If the URL isurl(fonts/KaTeX_AMS-Regular.woff2)
, then on/zh-CN/
it would look for/zh-CN/katex/fonts/KaTeX_AMS-Regular.woff2
which doesn't exist, because static assets aren't duplicated instatic/zh-CN
. We need to hardcode the full URL.(I did an initial attempt back in #7572 but made a little mistake by forgetting the
/katex/
prefix)@slorber Do we really want to self-host these assets?
Test Plan
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs