Ops,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
body, html{
height: 100%;
}
div.a {
opacity: 0;
}
div.a.b{
opacity: 1;
transition: 3s;
}
div.b::before {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
content: "";
background-image: var(--img, none);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
</style>
</head>
<body>
<div class="a"></div>
<script>
const img = new Image();
img.src = 'https://wallpaperscave.ru/images/original/18/06-22/earth-field-60178.jpg';
img.decode()
.then(() => {
document.querySelector('.a').style.setProperty('--img', `url(${img.src})`);
document.querySelector('.a').classList.add('b')
})
</script>
</body>
</html>