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

Add explainer for "font display late swap" #269

Merged
merged 4 commits into from
Jan 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions policies/font-display-late-swap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Font Display Late Swap Policy

## Objective
Late loading of webfonts can cause layout instability and late text rendering. By default, a fallback font gets rendered in place of the webfont which gets replaced when the font loads and causes elements to move depending on the differences between the fallback and the remote font. The objective is to prevent the page elements to move around because of this behavior.

## Solution
Introduce a new feature, namely, `font-display-late-swap` to control the value of `font-display` descriptor (more info on the `font-display` [here](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display)). When the feature is disabled in a frame, all the `font-display` values will be restricted to `optional` for the frame (except for when explicitly set to `fallback`).

## Usage
A page can use the `font-display-late-swap` feature by specifying it in its HTTP header:

```
Feature policy: font-display-late-swap 'none'
```

which would disable the feature on the page. Alternatively, it can be set by modifying the `allow` attribute in the `iframe` tag. for example:

```
<iframe src="https://example.com" allow="font-display-late-swap 'none'"></iframe>
```

would disable the feature in the embedded frame.