Skip to content

Instantly share code, notes, and snippets.

@mutongwu
Created November 15, 2022 03:00
Show Gist options
  • Save mutongwu/77955ec0ce9391fa02ba847cf13f7796 to your computer and use it in GitHub Desktop.
Save mutongwu/77955ec0ce9391fa02ba847cf13f7796 to your computer and use it in GitHub Desktop.

自定义字体,会阻塞浏览器对文本的渲染。 @font-face(https://developers.google.com/web/updates/2016/02/font-displayhttps://web.dev/optimize-webfont-loading/ )

@font-face { font-display : ‘auto’;  /*auto, swap, fallback, optional */} 

font-display 可以告诉浏览器,在字体加载完成前,先用系统字体显示,减少文本空白的情况。

新的提案建议: 在自定义字体完成加载之前,如果使用系统字体显示,虽然可以防止空白,但是如果自定义字体跟现有实现差异太大,渲染后会有很大的差别,用户体验不好。 新的提议对@font-face有size-adjust 属性控制,可以减少这种差异,给用户更加平滑的显示过渡。

https://www.smashingmagazine.com/2021/05/reduce-font-loading-impact-css-descriptors/

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