I want the background of my website to be images pulled from the internet, a new one every 5 seconds, I could make this work, but my screen flashes white every time a new image appears because it needs to load in. Is it possible to wait until the image loaded in and then show it?
Here is my current function to change the background to a random image from a list:
function newBackground() {
var url = urls[Math.floor(Math.random() * urls.length)];
body.style.backgroundImage = "url('" + url + "')";
}
This was fixed by the comment from yozibak, thank you