3 ms·
This article is a little bit outdated; should probably add "(2016)" to the title. These days you can use "font-display: fallback" and that's a fairly reasonable
by arp242 5y ago
This article is a little bit outdated; should probably add "(2016)" to the title. These days you can use "font-display: fallback" and that's a fairly reasonable trade-off between all the various things:
1. Wait very briefly (100ms) for the font to load, don't render anything yet.
2. If the font hasn't loaded then use a system font and render the page visibly, keep loading the font for another 3 seconds.
3. Substitute the font once it's loaded, or just continue with the system font if it's not.
If the webfont is small enough (~16k on my site, times three for italics and bold, ~50k in total) then this works quite well even on slower 2G connections.
One thing I also do is remove unused codepoints, which can reduce the size quite a bit. In my case, it reduced the size from ~150k to ~50k. I have a little script that just scans all text files in a directory and removes and codepoints that don't exist: https://github.com/arp242/ttftrim https://github.com/arp242/ttftrim
- dylan604 5y ago>this works quite well if you consider swapping a font and potentially the layout after the viewer has already started reading the intial load as working quite well, then we definitely have different definitions. the only thing more annoying would be if the layout changed because you threw an ad at me after intial layout
- Dylan16807 5y agoPersonally I'm not annoyed if it's only in the first couple seconds. And on only the first page load. But these days font-display: optional works just about everywhere too. Also on firefox you can configure the 3 seconds to be something else.
- arp242 5y agoFor a lot of visitors the page will just render fine in the 100ms, and 3 seconds is a reasonable timeout (it should never change the layout after that). Orienting yourself on the site before actually reading anything takes ~3s anyway, so it shouldn't change fonts in the middle of reading a paragraph. You can also configure this timeouts in your browser (hidden settings, but that's how it is these days) if you really don't like it.
- jazzyjackson 5y agoif you think not showing anything until a font loads is acceptable then I guess you and I just have nothing in common!
- dylan604 5y agoof course not. before you show any text, you have to download and display all of the ads first silly.