Будет менять по кругу все картинки из списка:
const pictures = [
{ src: 'src1', delay: 1000 },
{ src: 'src2', delay: 2000 },
{ src: 'src3', delay: 3000 },
{ src: 'src4', delay: 4000 },
]
let current = 0;
function nextImage () {
var img = new Image;
img.src = pictures[current].src;
img.onload = function () {
document.body.style.backgroundImage = 'url(' + pictures[current].src + ')';
current++;
if (current >= pictures.length) current = 0;
setTimeout(nextImage, pictures[current].delay);
}
}
nextImage();