I believe most of the visitors of this question are looking for the answer of "How can I preload an image before the page's render starts?" and the best solution for this problem is using <link>
tag because <link>
tag is capable to block the further rendering of the page. See preemptive
These two value options of rel
(relationship between the current document and the linked document) attribute are most relevant with the issue:
So if you want to load a resource (in this case it's an image) before the rendering process of <body>
tag starts, use:
<link rel="preload" as="image" href="IMAGE_URL">
and if you want to load a resource while <body>
is rendering but you are planning to use it later on dynamically and don't wanna bother the user with loading time, use:
<link rel="prefetch" href="RESOURCE_URL">