body.background__loaded {
  opacity: 1;
  background-image: url("https://images.unsplash.com/photo-1444703686981-a3abbc4d4fe3?crop=entropy&dpr=2&fit=crop&fm=jpg&h=750&ixjsv=2.1.0&ixlib=rb-0.3.5&q=50&w=1450");
}

body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  
  transition: all 1s ease-in-out;

  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDI0IiBoZWlnaHQ9IjUyOCI+PHBhdGggZmlsbD0iIzUzNDAzMSIgZD0iTTAgMGgxMDI0djUyOEgweiIvPjxnIGZpbGwtb3BhY2l0eT0iLjUwMiI+PHBhdGggZmlsbD0iI2ZmZGFiMiIgZD0iTTI1OCA0OTRMNTQ2IDUwbDM1MiAzODB6Ii8+PHBhdGggZD0iTTU0Ni02MkwtNjIgMTBsODggNTgwek02MTAgNTU4bDQyMCA0VjMxNHoiLz48cGF0aCBmaWxsPSIjMDAwMDA2IiBkPSJNMTA4NiA2TDU5MC0yNmw0ODggMzMyeiIvPjxwYXRoIGQ9Ik00ODYgNTUwbC01MjQgMjQgMTYtMjk2eiIvPjxwYXRoIGZpbGw9IiM5ZmJkOTgiIGQ9Ik05MjYgMzc4TDgxNCAxMzQgNTIyIDUxOHoiLz48cGF0aCBmaWxsPSIjZjQ5YTcwIiBkPSJNNzEwIDQ4NmwtNTA0LTYwIDI5Mi0zMjB6Ii8+PHBhdGggZmlsbD0iIzkzNGMwMCIgZD0iTTM1NCA1MTBMOTQgMzU4bDI2NC0yMzJ6Ii8+PHBhdGggZmlsbD0iIzQ3NDI1ZiIgZD0iTTYxOCAyNTRsNDY4IDhMNDQyLTYyeiIvPjxwYXRoIGQ9Ik00NDItMzhMLTYyIDQxMFYtMjZ6TTEwMzAgNTkwbDIwLTMyMC0zMjQgMjY4eiIvPjxwYXRoIG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iLz48cGF0aCBmaWxsPSIjY2E3NTc1IiBkPSJNMzc0IDI5NGw4NC01MiAyOCAxMDB6Ii8+PHBhdGggZmlsbD0iIzliNjEwMCIgZD0iTTIxOCAzMThsMTU2IDE2OC0xMTYtNDR6Ii8+PHBhdGggZmlsbD0iI2U2YTlhMSIgZD0iTTUzOCA0MzBsLTY4LTE1NiA5MiA4eiIvPjxwYXRoIGZpbGw9IiM1NjJhMzIiIGQ9Ik03MzAgMTIyTDU5NC0xNGw4IDEzMnoiLz48cGF0aCBmaWxsPSIjMjI0NzQ0IiBkPSJNOTU0IDM1OGwtNzItMjQwIDE0MCAxNDh6Ii8+PC9nPjwvc3ZnPg==");
}
const imageSrc = `https://images.unsplash.com/photo-1444703686981-a3abbc4d4fe3?crop=entropy&dpr=2&fit=crop&fm=jpg&h=750&ixjsv=2.1.0&ixlib=rb-0.3.5&q=50&w=1450`;
// const imageURL = `url(${imageSrc})`;
const body = document.body;
const background = body;

// Approximate jQuery's document.ready(...) equivalent
// https://stackoverflow.com/a/21814964/4035
document.addEventListener("DOMContentLoaded", function() {
  let image = new Image();
  image.src = imageSrc;

  image.onload = setTimeout(() => {loadBackgroundImage()}, 1000);
});

const loadBackgroundImage = () => {
  background.classList.add("background__loaded");
};
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.