let head = new Image();
head.src = "img/head.png";
if(!head.complete)
console.log('NOT');
In the code above I am getting NOT in my log for the first time the page loads and then when I refresh the page nothing is logged as the image loads. How to force load the image in first page load?
I have referred to many answers on SO but nothing has helped till now. I used onload
but the image is just not loading on the first load as I checked it using head.complete
. I even added a timestamp at the end of the image "head.png?"+getTime(new Date())
if there was a problem regarding caching.. But no luck!
And all other images are loading perfectly.