I'm trying to find out which one loads faster. Upon checking the audit tab in Chrome both approach result in a slow First meaningful paint. I'm using googleapi font to render fonts in my site. Below are the codes I'm comparing
<link href='https://fonts.googleapis.com/css?family=Montserrat&subset=latin' rel='stylesheet'>
vs
@font-face {
font-family: 'Montserrat';
src: url('../fonts/Montserrat/Montserrat-Regular.ttf') format('truetype');
}
Now it seems that hosting the font on my local directory loads slower. I'm not sure if what I'm doing is correct. Any idea which one is faster and what is the best way to implement this?
I'm just trying to cut down the First meaningful paint down to half. I used the link in to reference the googleapi but upon checking the audit its taking 1,500ms just to load this from googleapi site.
<head>
tag will be loaded before everything else. If you put it inside thecss
file, it loads it after thecss
file has been loaded. – Tabulatoror
? Those are the same thing: the link you show points to a CSS file with (lots of)@font-face
rules. So technically the link is slower because in both cases it's the same CSS, just one is direct and the other requires following a link source, but practically this should be entirely irrelevant. If your page is so fast that you can't even measure the difference in speed yourself, this is not a problem even worth asking about. – Basketballunicode-range
property, it's only been more sensible to use<link>
since they switched to sending browsers good font-face CSS =) – Basketball