This code switches the background between two different images. However when it switches from the first image to the second there is always a one second buffer before the image gets displayed and this only happens the very first time the images switch. How can I get rid of the buffer?
function changeBgColor(){
var img = ['url(img/mechanic.jpg)', 'url(img/start.jpg)'];
var nImg = img.length;
var currentImg = 0;
document.body.style.backgroundImage = "url(img/start.jpg)";
document.body.style.backgroundSize = "cover";
document.body.style.backgroundRepeat = "no-repeat";
var imgChange = setInterval(function(){
document.body.style.backgroundImage = img[currentImg];
document.body.style.backgroundSize = "cover";
document.body.style.backgroundRepeat = "no-repeat";
if(currentImg == nImg-1){
currentImg = -1;
}
currentImg++;
},10000);
}