const maxFiles = 50;
const randomEl = document.getElementById("random");
function randombg() {
var random = Math.floor(Math.random() * maxFiles) + 1;
randomEl.style.backgroundImage = `url('images/ (${random}).jpeg')`
}
randombg();
I have the above code that randomly generates background image to body which id is random
. Because the images that I load are at very high resolution the loading is not smooth. How can I add lazy load so the whole image will load at once?