In order for the browser to preload the image into the cache, you can use some of your own JavaScript objects.
var imgPreload = new Image(); imgPreload.src = PATH_TO_IMAGE;
Now that you give the <img>
tag the src
attribute, which matches PATH_TO_IMAGE
, it has already been preloaded by the browser.
<img src="PATH_TO_IMAGE" width="100%" >
You can also load some images into your HTML and just use some CSS tricks to hide them -
display:none
or
visibility:hidden
and then display them only when fully loaded. You can use the .load()
function for this. Just attach it to the <img>
-
$("#imageSelector").load(function(){
source share