Git Product home page Git Product logo

hamzaerbay / web-font-loading-recipes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zachleat/web-font-loading-recipes

0.0 2.0 0.0 497 KB

A bunch of demos for different web font loading strategies. Companion to https://www.zachleat.com/web/comprehensive-webfonts/ Read more: https://www.zachleat.com/web/recipes/

Home Page: https://www.zachleat.com/web-fonts/demos/

License: MIT License

HTML 100.00%

web-font-loading-recipes's Introduction

web-font-loading-recipes

A bunch of demos for different web font loading strategies. Some of these are included on A Comprehensive Guide to Font Loading Strategies, some of them are more experimental.

Demos are hosted at https://www.zachleat.com/web-fonts/demos/

Recommended Methods

As web fonts are a progressive enhancement and with increasing support for the CSS Font Loading API, we can look forward to a time in which we won’t need to inline a polyfill into the header (for even faster font loading). The simplified CSS Font Loading API recipes are the defaults, but polyfilled versions are included for broader browser support. In practice this means only the polyfilled versions will show web fonts in Internet Explorer and Edge web browsers (which do not have support for the CSS Font Loading API).

Experiments in Progress

You’ll probably see blog posts on these at some point.

  • FOUT metric matching with a Variable Font
    • Reduction in FOUT reflow (reduce text movement on web font render)
    • Related: Font style matcher from @notwaldorf
  • Emulate font-display: optional with JS (the eBay method)
    • Notable in that it lazy loads the font loading polyfill only if the CSS Font Loading API is not supported
  • (To be named) Any recommended non-polyfilled recipe above with one slight variation: it uses the eBay method if the CSS Font Loading API is not supported (in practice this means font-display: optional only on IE/Edge). This is what I’m currently doing on zachleat.com.
  • FOUT without a class
    • Doesn’t require any modification of the CSS, injects the web fonts using JS programmatically (the Asynchronous Data URI method below also does this). Documented in the Webfont Handbook from @bramstein.

Not Recommended but included for Posterity

Deprecated Methods

Failed Experiments

  • @supports and font-display
    • Reasons for trying:
      • might be nice to only use web fonts if you can FOUT with font-display
      • might be nice to have FOUT with a class if font-display not supported (and work well without JS dependencies)
    • Failed: @supports doesn’t work with font-face descriptors.
    • Demo

** Take note that these methods will FOUT in Internet Explorer and Edge by taking advantage of their default font loading behavior.

web-font-loading-recipes's People

Contributors

zachleat avatar

Watchers

Hamza Erbay avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.