html - Loading font-face before img src -


given simple html page made of text , several image tags, css, without javascript, there way tell browser load font-face urls before image sources?

it seems many browsers wait until first occurrence of tag requires font-family before requesting font (source).

however, if place tag style="font-family: 'libre_baskerville' !important" @ top of body, doesn't trigger request until after image tags sources have been requested, seen here:

enter image description here

this causes issues due browsers' (and http spec itself) maximum concurrent connections same domain. since images triggered first, browser has load images before can draw text.

the images, being larger files, can take longer download font-face. however, text typically more important (and certainly, text in first few lines more important image below fold).

a couple of potential solutions i've considered:

possible solution #1:

avoid using <img> tags, , use tag css background-image. has disadvantage of losing semantic meaning image tags provide. requires rules set width , height of tag match image; these dimensions may not both known, , if it's still more maintain. not work if css not enabled (though isn't big concern).

swapping out images tags each have background-image set allows following order network connections: enter image description here

possible solution #2:

host font (or, potentially, images) on separate different domain. while won't change order in files requested, prevent "maximum concurrent connections same domain" issue.

this has disadvantage of adding dependencies (increasing chances of down-time, latency, etc.), having manage multiple domains fonts. cheats providing means of avoiding question, rather answer - though provides practical results.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -