html - Google Fonts loading explained -
i'd know, how google fonts finds out, fonts load. example when use inside css
@import '//fonts.googleapis.com/css?family=roboto:300'; it returns css interpreted (the loading of resource blocks browser rendering afaik):
/* cyrillic-ext */ @font-face { font-family: 'roboto'; font-style: normal; font-weight: 300; src: local('roboto light'), local('roboto-light'), url(http://fonts.gstatic.com/s/roboto/v15/0ec6fl06luxeywpbsjvxcix0hvgzzqufrduzrpvh3d8.woff2) format('woff2'); unicode-range: u+0460-052f, u+20b4, u+2de0-2dff, u+a640-a69f; } /* cyrillic */ @font-face { font-family: 'roboto'; font-style: normal; font-weight: 300; src: local('roboto light'), local('roboto-light'), url(http://fonts.gstatic.com/s/roboto/v15/fl4y0qdoxyythegmxx8kcyx0hvgzzqufrduzrpvh3d8.woff2) format('woff2'); unicode-range: u+0400-045f, u+0490-0491, u+04b0-04b1, u+2116; } // ...and more i thought, when provide url(...) inside css, browser loads resource immediately.
however, when open pen http://codepen.io/anon/pen/egkver , have @ network tab (maybe clear cache) can see loads 2 resources: http://fonts.googleapis.com/css?family=roboto:300 , http://fonts.gstatic.com/s/roboto/v15/hgo13k-tfspn0qi1sfdufzbw1xu1rkptjj_0jans920.woff2 normal latin range (defined @ bottom of loaded font css):
/* latin */ @font-face { font-family: 'roboto'; font-style: normal; font-weight: 300; src: local('roboto light'), local('roboto-light'), url(http://fonts.gstatic.com/s/roboto/v15/hgo13k-tfspn0qi1sfdufzbw1xu1rkptjj_0jans920.woff2) format('woff2'); unicode-range: u+0000-00ff, u+0131, u+0152-0153, u+02c6, u+02da, u+02dc, u+2000-206f, u+2074, u+20ac, u+2212, u+2215, u+e0ff, u+effd, u+f000; } so, browser @ characters use, , load used font? or depend on browser settings? can't find resource documents behaviour (or i'm searching wrong keyword). i suspect has
unicode-range:@ bottom of css.
the browser reads
@importinstruction tells him load css page served google: http://fonts.googleapis.com/css?family=roboto:300. page loaded instantly.in page, there
url()instructions tell browser font files located. the browser doesn't download these fonts until needs them. example, if font never used element, browser won't download it.
i suspect has
unicode-range: @ bottom of css.
yes, that's it. unicode-range specifies class of characters font include (for example, cyrillic characters). if there aren't characters of rage inside page, fonts won't downloaded.
for reference: https://en.wikipedia.org/wiki/unicode_block
Comments
Post a Comment