ebay-font is the module used at eBay to load custom web fonts. It uses a strategy to avoid both FOUT and FOIT. This can be considered equivalent to the new CSS
font-display: optional. Unfortunately,
font-display is relatively new and hence its adoption among browsers is not widespread. So for now, this module leverages
FontFaceSet API and the Font Face Observer utility (as a backup if
FontFaceSet API is not present) to provide the same functionality as
ebay-font is paired along with eBay's custom font 'Market Sans'. But feel free to change it to any custom font URL of your choice.
Please refer to the detailed blog post "eBay’s Font Loading Strategy" for a full overview of how this module works.
- Install and save the module
npm install ebay-font --save
- Add dependency in your page
- The module exposes a tag
<ebay-font>to embed in the
<head>tag of page HTML
- Note: If your website uses Content Security Policy (CSP), you can pass the CSP nonce value to
<head>tag of your page
- Chrome (desktop & Android)
- Safari (desktop & iOS)
- Android WebKit
Have a bug or a feature request? Please open a new issue
Open browser issues
- Chrome — Very randomly on a new session, all font formats are getting downloaded if
font-displayis present in the
font-face. Filed a bug to track it.
Pull Requests welcome. Please submit Github issues for any feature enhancements, bugs or documentation problems.
Copyright (c) 2017 eBay Inc.
Released under the MIT License