Skip to content

Inline critical font - #16031

Merged
wjordan merged 1 commit into
stagingfrom
critical-font
Jun 22, 2017
Merged

Inline critical font#16031
wjordan merged 1 commit into
stagingfrom
critical-font

Conversation

@wjordan

@wjordan wjordan commented Jun 22, 2017

Copy link
Copy Markdown
Contributor

This PR introduces a 'critical font' feature using the CSS Font Loading API (supported in most non-IE browsers). This inlines a tiny (~5k gzipped), 'critical' subset of our font ([ 0-9A-Za-z] glyphs in a single weight/style) that renders immediately as soon as the page is loaded. The full font (all glyphs, weights/styles, ~100k gzipped) is lazy-loaded, and swapped in once it fully loads.

This is a calculated tradeoff: the downside is that there's a slight shift in the text once the full font is fully loaded, but the upside is that the page renders sooner because it's not blocked waiting for the full font to load first.

Here's what that shift looks like:

load

The only visible shifts should be in bold-weight or italic styles (since the critical-font is only a single weight/style), and in punctuation glyphs (or other symbols not present in the critical font), which overall should be relatively minor.

Because of the slight impact on user-experience, the feature will apply only to select pages (marked with critical_font: true in the Pegasus header, currently only the homepage), and only for English-language pages for now (to avoid inconsistent user-experience in languages relying more heavily on other glyphs).

@wjordan
wjordan requested a review from breville June 22, 2017 17:56
@wjordan

wjordan commented Jun 22, 2017

Copy link
Copy Markdown
Contributor Author

Manually tested across browsers. Merging now to unblock related performance-testing, but will plan on followup changes for any feedback.

@wjordan
wjordan merged commit 519bbd4 into staging Jun 22, 2017
@wjordan
wjordan deleted the critical-font branch June 22, 2017 19:30

@breville breville left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants