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

Cache-busting for kit files and font links with preload attribute generates a FOUT. #686

Closed
artqvo opened this issue Apr 8, 2022 · 1 comment

Comments

@artqvo
Copy link

artqvo commented Apr 8, 2022

Quick, short summary:

I wanted to tell you about a problem I have encountered with the cache-busting option for kit files.

It has to do with some fonts that I preload. Enabling the cache-busting option also adds a hash to these links and that generates a warning in the console (which does not appear when it is not activated), but it also affects the stability of the layout, something that is especially noticeable in the header with the main menu.

Expected results:

Without activating it, when clicking (it is a «Jamstack» website, just html, css, and js files without any js framework) the loading is fast enough to give the feeling that it is a SPA, the top menu layout and elements remains completely stable between page loads.

Actual results:

However when activating the cache-bust (that add the hash to the fonts links) it seems that the font preload stops working or does it incorrectly and then there is an obvious glitch due to a FOUT. With which I am forced not to use the cache-bust, as it is very evident every time the user navigates through the main menu, regardless of the connection speed.

Exact steps to reproduce:

Add a font link in the header of the html page with the rel attribute as preload and enable cache-busting for .kit files. For example:

<link rel="preload" as="font" crossorigin type="font/woff2" href="/fonts/my-custom-font.woff2">

It would be interesting to have some configurable parameters in relation to the cache-bust as for example to be able to mark if you want to apply it to the links that load fonts or not, especially if they go with preload.

@bdkjones
Copy link
Owner

A longer-term strategy for dealing with all types of preload assets is probably still a good idea, but fonts are a bit unique because a cache miss will cause a style-jump on page load. I've updated the cache buster to skip .woff and .woff2 URIs. That'll go live in the next release.

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

2 participants