mgsloan / mgsloan-site

Source and site generator for https://mgsloan.com
GNU General Public License v3.0
5 stars 4 forks source link

Load bold and italic fonts, use single request #1

Closed ruuda closed 6 years ago

ruuda commented 6 years ago

I was just browsing Reddit, and then I stumbled upon a page that looked familiar. I like what you did to it :)

You missed one thing though; by default the Google Fonts API sends only a stylesheet that includes the regular weight and style. If you want bold and italic, you have to explicitly ask for them. Otherwise the browser will generate one, which doesn’t work very well for serif fonts.

Before: mgsloan1

After: mgsloan2

Also, all of the requests can be collapsed into one to reduce the number of roundtrips (when not using http/2) and to reduce the page size.

mgsloan commented 6 years ago

Awesome, thanks a bunch Ruud!

I had no idea that it could be done in a single request! I knew about the font weights, but I forgot they'd be used by formatting, and had no idea that the browser would try to generate one itself.

So yeah, I really appreciate this improvement and you sharing your site's code in the first place. Thanks!!

There are a few changes I've made that might be helpful to your site: