⚡️
1s
2s
3s
4s
5s
END OF THE UNIVERSE
jeremenichelli.io
@jeremenichelli
Season 9 Episode 15
Gimme me your money, punk!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link
href="https://fonts.googleapis.com/css?family=Lora|Oswald:700"
rel="stylesheet">
<title>Gimme your content, punk!</title>
</head>
<body>
...
</body>
</html>
body {
font-family: 'Lora', Georgia, Times New Roman, serif;
font-weight: 400;
}
h1, h2 {
font-family: 'Oswald', Helvetica, Arial, sans-serif;
font-weight: 700;
}
Flash of Invisible Text
Flash of Unstyled Text
import store from 'store-css' // by me, also possible with loadCSS by Filament group
import FontFaceObserver from 'fontfaceobserver' // by Bram Stein
// async load stylesheet with font declaration
store.css(
'https://fonts.googleapis.com/css?family=Open+Sans|Oswald:700',
{ crossOrigin: true }
)
// observe fonts
const bodyFamily = new FontFaceObserver('Lora').load()
const headingFamily = new FontFaceObserver('Oswald', { weight: 700 }).load()
// switch to web fonts when ready
bodyFamily.then(() => document.documentElement.classList.add('lora-ready'))
headingFamily.then(() => document.documentElement.classList.add('oswald-ready'))
body {
font-family: Georgia, Times New Roman, serif;
font-weight: 400;
}
.lora-ready body {
font-family: 'Lora';
}
h1, h2 {
font-family: Helvetica, Arial, sans-serif;
font-weight: 700;
}
.oswald-ready h1, .oswald-ready h2 {
font-family: 'Oswald';
}
@font-face {
font-family: YourWebFont;
src: url(/path/to/fonts/your-web-font.woff22) format('woff2'),
url(/path/to/fonts/your-web-font.woff) format('woff');
font-weight: 400;
font-style: normal;
font-display: swap;
}
font-display-late-swap
Tweet extracted from BuzzFeedJS parody account
Photos from Unsplash by Joel Fulgencio and Pau Casals