Skip to content

Instantly share code, notes, and snippets.

View nurullah's full-sized avatar
:atom:

Nurullah Sevinçtekin nurullah

:atom:
View GitHub Profile
@cvan
cvan / fontface-loading.js
Created October 8, 2019 23:24
loading fonts with JavaScript using `new FontFace` (to avoid FOUF)
(async function () {
async function loadFonts () {
if (!('FontFace' in window)) {
return;
}
const fonts = [
new FontFace('theinhardt', 'url(/fonts/akzidenz-grotesk/AkzidenzGrotesk-Light.woff2)'), // 400
new FontFace('theinhardt', 'url(/fonts/akzidenz-grotesk/AkzidenzGrotesk-Regular.woff2)'), // 500
new FontFace('theinhardt', 'url(/fonts/akzidenz-grotesk/AkzidenzGrotesk-Medium.woff2)'), // 600