Re: [csswg-drafts] [css-fonts] Add a `font-display` keyword to eliminate `@font-face` FOIT & layout shifts (#7271)

@heycam I think your code snippet has the same loading performance as mine. Both have the following timeline:

```
main document:                              |-----------------------------|
style sheet loading (by preload scanner):      |-------|
style sheet parsed & inserted into DOM:                       *
font loading (initiated by JS):                                |-------------|
rendering unblocked:                                                          *
```

But the original proposal can achieve:

```
main document:                              |-----------------------------|
style sheet loading (by preload scanner):      |-------|
style sheet parsed & inserted into DOM:                       *
font loading (by preload scanner):               |-------------|
rendering unblocked:                                            *
```

Besides loading performance, I'd also like to avoid using a parser-blocking script to call `document.fonts.load()`, otherwise the script will be blocked on previous style sheets (which are script-blocking), which means parsing of the document will be paused until all previous sheets are loaded. Using an inline `onload` event handler on the style sheet seems to fix it, but AFAIK inline event handlers are strongly discouraged and even banned in some cases ([reference](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#inline_event_handlers_%E2%80%94_dont_use_these))

-- 
GitHub Notification of comment by xiaochengh
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7271#issuecomment-1176801067 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 6 July 2022 22:11:30 UTC