By catch on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.4.x
Introduced in version:
11.4.0
Issue links:
Description:
Library definitions now support a fonts key, for preloading of fonts.
Previously Drupal did not provide an API for font preloading, although there were patterns such as adding the links manually to the html header template.
Fonts to be preloaded can now be declared at the same level as CSS and JavaScript in the library definition, and a <link rel="preload" element will be added to the HTML header programmatically.
Note that setting preload: false in a definition is the same as not including a font in the definition, it has no effect.
global-styling:
version: VERSION
fonts:
fonts/metropolis/Metropolis-Regular.woff2:
preload: true
Fonts should be preloaded when they're very likely to block rendering above the fold. See https://web.dev/learn/performance/optimize-web-fonts for more details
Impacts:
Module developers
Themers