Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Sia Karamalegos
Sia Karamalegos

Posted on • Edited on • Originally published atsia.codes

     

Day 4 of⚡️ #30DaysOfWebPerf ⚡️: Webfonts

Liquid error: internal

unknown tweet media content
Sia Karamalegos profile image
Sia Karamalegos
twitter logo
Let's take a look at the network profile waterfall...

LOL WAT IS HAPPENING?!?!
14:30 PM - 06 Nov 2019
Twitter reply actionTwitter retweet actionTwitter like action

unknown tweet media content
Sia Karamalegos profile image
Sia Karamalegos
twitter logo
So what is happening here?

1) HTML is loaded, kicking off...
2) Our CSS stylesheet load, kicking off...
3) The font stylesheet load, kicking off...
4) FINALLY OUR FONTS 🤦‍♀️

We can shorten the chain by moving the font request to our html:
14:30 PM - 06 Nov 2019
Twitter reply actionTwitter retweet actionTwitter like action

unknown tweet media content
Sia Karamalegos profile image
Sia Karamalegos
twitter logo
Let's run another network profile...

It's admittedly better, but wat still?

1) Our HTML link sets up a connection tofonts.googleapis.com and loads the font stylesheet
2) Our fonts are on a different domain so we need to set up ANOTHER CONNECTION. DNS + connect + SSL!!
14:30 PM - 06 Nov 2019
Twitter reply actionTwitter retweet actionTwitter like action

unknown tweet media content
Sia Karamalegos profile image
Sia Karamalegos
twitter logo
How fix? Preconnect!

Preconnect says, "Hey, I know I need to go to this domain really soon, so can you warm it up, Chris?"
14:30 PM - 06 Nov 2019
Twitter reply actionTwitter retweet actionTwitter like action

unknown tweet media content
Sia Karamalegos profile image
Sia Karamalegos
twitter logo
🎉¡TADA! 🎉

So now the browser will warm up that connection so it's sitting there waiting for thefonts.gstatic.com call. Then it can start loading those fonts immediately.

Without much code at all, we've made our site faster by optimizing for latency! 🎊
14:30 PM - 06 Nov 2019
Twitter reply actionTwitter retweet actionTwitter like action

Sia Karamalegos profile image
Sia Karamalegos
twitter logo
Y'all, if anyone has a better way to annotate images on screenshots (on a Mac) so I don't look like a serial killer anymore, I would very much appreciate the tips. I have a Pixelbook too if it's just way easier there.
14:30 PM - 06 Nov 2019
Twitter reply actionTwitter retweet actionTwitter like action

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
tails128 profile image
Tails128
I am a dev from Italy, currently working in the videogames field in Germany!Like: photos, videogames, learning!
  • Location
    Germany
  • Work
    Software developer at GoodGame studios
  • Joined

I totally removed thepreconnect attribute from my mind... thanks for reminding!

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Front-end developer passionate about web performance, international conference speaker and Google Developers Expert
  • Location
    New Orleans, LA
  • Work
    Founder & Lead Developer at Clio + Calliope
  • Joined

More fromSia Karamalegos

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp