javascript - Earliest preload for an image in an HTML page -


what earliest possible time in html page load sequence image request can issued?

a site involved switching using sprite pages. sprite page potentially large, , overall page load time of first page benefits request being issued browser. pages include heavy css , js loads , terrible initiate sprite-page load after these complete.

the quickest overall load time i've found create ultra-short css file, referred in html head section, references image in class. typically initiates image request before other css , js have finished loading (number of connections permitting) in modern browsers. other techniques seem delay @ least until css loaded before initiating image request.

i dislike technique, however, introduces 1 more round-trip , 1 more file seems necessary, might add 50ms-100ms or load time compared technique initiates image request direct html. however, referring image in html body, etc, seem cause request wait until head css loaded. , more obvious solutions -- not sweating it, referring naturally in main css, including image in body -- robustly slower around 200ms-300ms in (bloated) application.

maybe there way reference image extremely in html head might cause @ least modern browsers load extremely early? (some special, weird kind of link tag, maybe?

any online explanation of modern load-order of benefit (but not answer question).

we have good, robust load-time test based on headless browsers allows test load-times 10ms accuracy variety of artificial latencies , bandwidths on realistic profile of our pages, , these differences statistically significant. i'm happy take untested proposals in answers , put through framework.

[i'm aware in many cases data-urls in css , icons dingbats in woffs better techniques sprite-pages, that's not true in cases of images (which have data show), , use of sprite-pages part of migration path complex application].

i suggest inline css part html, e.g:

<head>   <title>(...)</title>   <style>     /* inline style */   </style>   <!-- other link tags, maybe scripts, etc --> </head> 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -