Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Webfont Performance

Webfont Performance

Inzwischen ist die Einbettung von Webfonts in Webprojekte zum Basishandwerk eines jeden Front End Developers geworden. Doch wird auch schon genügend hinterfragt, wie weit dessen Verwendung die Ladeperformance der Website beeinflussen kann? In diesem Talk, präsentiert am Webclerks Meetup (http://www.meetup.com/de-DE/webclerks/) ging es darum, Performance-Hindernisse von Webfonts aufzuzeigen und Lösungswege zu liefern, wie Webfonts optimiert in Webprojekte eingebunden werden können.

Franziska Eder

June 15, 2016
Tweet

Other Decks in Technology

Transcript

  1. Meow for food, then when human fills food dish, take

    a few bites of food and continue meowing hola te quiero i am the best Cat ipsum dolor sit amet, ears back wide eyed, chew foot chase dog then run away. Fall asleep on the washing machine stare out the window i am the best. Asdflkjaert- vlkjasntvkjn (sits on keyboard) stare at wall turn and meow stare at wall some more meow again continue staring fall over dead (not really but gets sypathy). Lick butt and make a weird face cat slap dog in face but eat the fat cats food so meow all night having their mate disturbing sleeping humans and then cats take over the world and howl uncontrollably for no reason yet make Flash of Invisible Text (FOIT) Request Content ladet Webfonts geladen Inspiriert von: http://bramstein.com/
  2. FLASH OF UNSTYLED TEXT (FOUT) Meow for food, then when

    human fills food dish, take a few bites of food and continue meowing hola te quiero i am the best Cat ipsum dolor sit amet, ears back wide eyed, chew foot chase dog then run away. Fall asleep on the washing machine stare out the window i am the best. Asdflkjaert- vlkjasntvkjn (sits on keyboard) stare at wall turn and meow stare at wall some more meow again continue staring fall over dead (not really but gets sypathy). Lick butt and make a weird face cat slap dog in face but eat the fat cats food so meow all night having their mate disturbing sleeping humans and then cats take over the world and howl uncontrollably for no reason yet make Meow for food, then when human fills food dish, take a few bites of food and continue meowing hola te quiero i am the best Cat ipsum dolor sit amet, ears back wide eyed, chew foot chase dog then run away. Fall asleep on the washing machine stare out the window i am the best. Asdflkjaert- vlkjasntvkjn (sits on keyboard) stare at wall turn and meow stare at wall some more meow again continue staring fall over dead (not really but gets sypathy). Lick butt and make a weird face cat slap dog in face but eat the fat cats food so meow all night having their mate disturbing sleeping humans and then cats take over the world and howl uncontrollably for no reason yet make Request Content ladet Webfonts geladen Inspiriert von: http://bramstein.com/
  3. FOIT vs. FOUT Chrome Firefox Safari Opera IE9 IE10 IE11

    Edge FOIT FOIT FOIT FOIT FOUT FOUT FOUT FOUT
  4. Chrome Firefox Safari Opera IE9 IE10 IE11 Edge FOIT FOIT

    FOIT FOIT FOUT FOUT FOUT FOUT FOIT vs. FOUT
  5. Chrome Firefox Safari Opera IE9 IE10 IE11 Edge FOIT FOIT

    FOIT FOIT FOUT FOUT FOUT FOUT 3 Sek. 3 Sek. ∞ 3 Sek. n/a n/a n/a n/a FOIT vs. FOUT
  6. A WEBFONT IS ONLY DOWNLOADED WHEN IT IS USED IN

    A CSS SELECTOR THAT MATCHES A DOM CONNECTED NODE.
  7. <p>Text</p> _________________________________________ @font-face { font-family: MyFontRegular; src: url(myfont.woff2) format(“woff2”), url(myfont.woff)

    format(“woff”); } p { font-family: MyFontRegular, Arial, sans-serif; } EINE WEBFONT WIRD VOM BROWSER RUNTERGELADEN WENN:
  8. <p>Text</p> <p></p> Chrome, Opera, Safari, Android-Browser laden die Webfont MIT

    Content runter Firefox, IE, Edge laden die Webfont OHNE Content runter
  9. Font Loading 100 ms 200 ms 300 ms 400 ms

    500 ms 600 ms 700 ms HTML Inspiriert von: http://bramstein.com/
  10. Font Loading 100 ms 200 ms 300 ms 400 ms

    500 ms 600 ms 700 ms HTML CSS Inspiriert von: http://bramstein.com/
  11. <p>Text</p> _________________________________________ @font-face { font-family: MyFontRegular; src: url(myfont.woff2) format(“woff2”), url(myfont.woff)

    format(“woff”); } p { font-family: MyFontRegular, Arial, sans-serif; } EINE WEBFONT WIRD VOM BROWSER RUNTERGELADEN WENN:
  12. Font Loading 100 ms 200 ms 300 ms 400 ms

    500 ms 600 ms 700 ms HTML CSS MyFontRegular MyFontBold Font Loading beginnt Inspiriert von: http://bramstein.com/
  13. Font Loading 100 ms 200 ms 300 ms 400 ms

    500 ms 600 ms 700 ms HTML CSS MyFontRegular MyFontBold Font Loading beginnt 1. Font fertig gerendert Inspiriert von: http://bramstein.com/
  14. Font Loading 100 ms 200 ms 300 ms 400 ms

    500 ms 600 ms 700 ms HTML CSS MyFontRegular MyFontBold Font Loading beginnt Webfonts fertig gerendert Inspiriert von: http://bramstein.com/
  15. @font-face { font-family: MyFont; src: url(myfont.woff2) format(“woff2”), url(myfont.woff) format(“woff”); font-display:

    auto|block|swap|fallback|optional; } CSS FONT-DISPLAY CSS font-display ist so neu, wird daweil nur von Chrome und Opera unterstützt.
 Für die Zukunft merken!
  16. Font Loading 100 ms 200 ms 300 ms 400 ms

    500 ms 600 ms 700 ms HTML CSS MyFontRegular MyFontBold Font Loading beginnt Webfonts fertig gerendert Inspiriert von: http://bramstein.com/
  17. @font-face { font-family: MyFont; src: url('myfont.eot'); src: url('myfont.eot#iefix') format('embedded-opentype'), url('myfont.ttf')

    format('truetype'), url('myfont.woff') format('woff'), url('myfont.svg#myfont') format('svg'); } @FONT-FACE BISHER
  18. @font-face { font-family: MyFont; src: url(myfont.woff2) format(“woff2”), url(myfont.woff) format(“woff”); }

    @FONT-FACE JETZT Wenn IE8, < 4.4 Android und andere ältere Browser nicht mehr unterstützt werden müssen.
  19. @font-face { font-family: MyFont; src: url(myfont.woff2) format(“woff2”), url(myfont.woff) format(“woff”), url(myfont.ttf)

    format(“truetype”); } @FONT-FACE JETZT Wenn IE8 und andere ältere Browser nicht mehr unterstützt werden müssen.
  20. ALLE ZEICHEN, DIE NICHT GEBRAUCHT WERDEN, KÖNNEN ENTFERNT WERDEN Grafik

    ausgeborgt von:
 https://vimeo.com/145055818
  21. Font Loading 100 ms 200 ms 300 ms 400 ms

    500 ms 600 ms 700 ms HTML CSS MyFontRegular MyFontBold Font Loading beginnt Webfonts fertig gerendert Inspiriert von: http://bramstein.com/
  22. Font Loading 100 ms 200 ms 300 ms 400 ms

    500 ms 600 ms 700 ms HTML CSS MyFontRegular MyFontBold Font Loading beginnt Webfonts fertig gerendert Inspiriert von: http://bramstein.com/
  23. Font Loading 100 ms 200 ms 300 ms 400 ms

    500 ms 600 ms 700 ms HTML CSS MyFontRegular MyFontBold Font Loading beginnt Webfonts fertig gerendert Inspiriert von: http://bramstein.com/
  24. <head> <link rel="preload" href="MyFont.woff" as="font" type="font/woff"> <link rel="preload" href="MyFontBold.woff" as="font"

    type="font/woff"> </head> PRELOAD HINTS Auch Preload ist so neu und wird auch daweil nur von Chrome und Opera unterstützt.
 Für die Zukunft merken! —> http://caniuse.com/#search=preload https://www.bramstein.com/writing/preload-hints-for-web-fonts.html
  25. var myFont = new FontFace(‘myfont’, ‘url(MyFont.woff)’); var html = document.documentElement;

    myFont.load().then(function () { // font is loaded html.classList.add(‘fonts-loaded’); }); CSS FONT LOADING API
  26. <p>Text</p> _________________________________________ @font-face { font-family: MyFontRegular; src: url(myfont.woff2) format(“woff2”), url(myfont.woff)

    format(“woff”); } p { font-family: MyFontRegular, Arial, sans-serif; } EINE WEBFONT WIRD VOM BROWSER RUNTERGELADEN WENN:
  27. body { font-family: Arial, sans-serif; } .fonts-loaded body { font-family:

    MyFont, Arial, sans-serif; } CSS FONT LOADING API
  28. FLASH OF UNSTYLED TEXT (FOUT) Meow for food, then when

    human fills food dish, take a few bites of food and continue meowing hola te quiero i am the best Cat ipsum dolor sit amet, ears back wide eyed, chew foot chase dog then run away. Fall asleep on the washing machine stare out the window i am the best. Asdflkjaert- vlkjasntvkjn (sits on keyboard) stare at wall turn and meow stare at wall some more meow again continue staring fall over dead (not really but gets sypathy). Lick butt and make a weird face cat slap dog in face but eat the fat cats food so meow all night having their mate disturbing sleeping humans and then cats take over the world and howl uncontrollably for no reason yet make Meow for food, then when human fills food dish, take a few bites of food and continue meowing hola te quiero i am the best Cat ipsum dolor sit amet, ears back wide eyed, chew foot chase dog then run away. Fall asleep on the washing machine stare out the window i am the best. Asdflkjaert- vlkjasntvkjn (sits on keyboard) stare at wall turn and meow stare at wall some more meow again continue staring fall over dead (not really but gets sypathy). Lick butt and make a weird face cat slap dog in face but eat the fat cats food so meow all night having their mate disturbing sleeping humans and then cats take over the world and howl uncontrollably for no reason yet make Request Content ladet Webfonts geladen Inspiriert von: http://bramstein.com/
  29. var myFont = new FontFaceObserver(‘myfont’, …); myFont.load().then(function () { //

    font is loaded }); FONT FACE OBSERVER https://fontfaceobserver.com/ von Bram Stein
  30. if (sessionStorage.fontsLoaded) { html.classList.add(‚fonts-loaded’); return; } myFont.load().then(function () { //

    font is loaded html.classList.add(‘fonts-loaded’); sessionStorage.fontsLoaded = true; }); … OPTIMIERUNG AB DEM 2. RELOAD
  31. LINKS • http://bramstein.com/ • https://fontfaceobserver.com/ • https://vimeo.com/168474761 • https://speakerdeck.com/bramstein/web-fonts-performance-1 •

    http://bramstein.com/writing/web-font-loading-patterns.html • https://www.zachleat.com/web/ • https://vimeo.com/145055818 • https://vimeo.com/118908533 • https://helloanselm.com/2015/using-webfonts-in-2015/ • https://www.bramstein.com/writing/preload-hints-for-web-fonts.html • https://matuzo.at/webfont-performance/