Slide 1

Slide 1 text

Ok, but why is this important?

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Reith

Slide 4

Slide 4 text

Arial Gill Sans Georgia Curious Helvetica Verdana

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

“So, you want to load a custom font?” The Engineers

Slide 7

Slide 7 text

@font-face { font-family: "MySuperCoolFont"; src: url("/static/font.woff2"); } body { font-family: "MySuperCoolFont", Sans; }

Slide 8

Slide 8 text

The End Engineer Product Owner

Slide 9

Slide 9 text

Not quite…

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

1. Caching

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

src: url(“/gel/static/font.woff2"); src: url(“/gel/static/font.woff2"); src: url(“/news/static/font.woff2"); src: url(“/news/static/font.woff2"); src: url(“/sport/static/font.woff2"); src: url(“/sport/static/font.woff2"); src: url(“/iwonder/static/font.woff2"); src: url(“/iwonder/static/font.woff2"); src: url(“/cbbc/static/font.woff2"); src: url(“/cbbc/static/font.woff2"); src: url(“/weather/static/font.woff2"); src: url(“/weather/static/font.woff2"); src: url(“/music/static/font.woff2"); src: url(“/music/static/font.woff2"); src: url(“/cbeebies/static/font.woff2"); src: url(“/cbeebies/static/font.woff2"); src: url(“/earth/static/font.woff2"); src: url(“/earth/static/font.woff2"); src: url(“/food/static/font.woff2"); src: url(“/food/static/font.woff2");

Slide 14

Slide 14 text

Reith Sans Reith Sans Reith Sans Reith Sans

Slide 15

Slide 15 text

Reith Sans Reith Sans Reith Sans Reith Sans

Slide 16

Slide 16 text

2. Weight

Slide 17

Slide 17 text

Reith Sans Regular Reith Sans Medium Reith Sans Light Reith Sans Bold Reith Sans Extra Bold Reith Sans Regular Italic Reith Sans Medium Italic Reith Sans Light Italic Reith Sans Bold Italic Reith Sans Extra Bold Italic Reith Serif Regular Reith Serif Medium Reith Serif Light Reith Serif Bold Reith Serif Extra Bold Reith Serif Regular Italic Reith Serif Medium Italic Reith Serif Light Italic Reith Serif Bold Italic Reith Serif Extra Bold Italic

Slide 18

Slide 18 text

20 Font Files at ~50KB each

Slide 19

Slide 19 text

40 Font Files at ~50KB each

Slide 20

Slide 20 text

2MB

Slide 21

Slide 21 text

Other 20kB Images 1818kB HTML 53kB Stylesheets 90kB Scripts 459kB Fonts 113kB Video 819kB Average Bytes per Page Total: 3.4MB Source: httpdarchive.org

Slide 22

Slide 22 text

Cache: Set Max Age to at least 1 year Compress: use WOFF and/or WOFF2. Only load what you need

Slide 23

Slide 23 text

@font-face { font-family: "MySuperCoolFont"; src: url("/static/font.woff2"); } page.html style.css

My Super Cool Website

Slide 24

Slide 24 text

@font-face { font-family: "MySuperCoolFont"; src: url("/static/font.woff2"); } .cool-font { font-family: "MySuperCoolFont", Sans; } page.html style.css

My Super Cool Website

Slide 25

Slide 25 text

3. Performance

Slide 26

Slide 26 text

FOIT Flash Of Invisible Text

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

document stylesheet.css Readable Paint font.woff time Very Approximate Timeline Of Page Load Final Paint

Slide 30

Slide 30 text

Flash Of Unstyled Text with Class

Slide 31

Slide 31 text

FOUT with Class

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

This is some text.

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

This is some text

Slide 36

Slide 36 text

This is some text.

Slide 37

Slide 37 text

if (document.documentElement.className.indexOf('cool-font')!=-1) { var coolFont = new FontFaceObserver('MySuperCoolFont'); coolFont.load() .then(() =>{ document.documentElement.className += " cool-font-loaded"; }) .catch((e) =>{ console.log('Failed to load super cool font'); }) }

Slide 38

Slide 38 text

Welcome to my super cool website

page.html style.css @font-face { font-family: "MySuperCoolFont"; src: url("/static/font.woff2"); } html { font-family: Arial, sans; } html.cool-font-loaded { font-family: “MySuperCoolFont", Arial, Sans; }

Slide 39

Slide 39 text

Welcome to my super cool website

page.html @font-face { font-family: "MySuperCoolFont"; src: url("/static/font.woff2"); } html { font-family: Arial, sans; } html.cool-font-loaded { font-family: “MySuperCoolFont", Arial, Sans; } style.css

Slide 40

Slide 40 text

document stylesheet.css Readable Paint font.woff time Very Approximate Timeline Of Page Load Final Paint

Slide 41

Slide 41 text

4. Things we couldn’t use

Slide 42

Slide 42 text

1. Cache 2. Weight 3. Performance 4. Things we couldn’t use Custom Web Fonts

Slide 43

Slide 43 text

Working Across Silos

Slide 44

Slide 44 text

Useful Links: •Google Web Font Optimisation •Zach Leat’s Comprehensive Guide To Font Loading Strategies •Blog about BBC Reith Font

Slide 45

Slide 45 text

The End

Slide 46

Slide 46 text

bbc.co.uk/gel @BBCGEL @tsoukn @joehart