Want to fetch an image using javascript from CSS URL so I can style the background image with background-size: cover and colour. The code is used for simply Fast Image Loading With Javascript
var image = document.images[0]
var bigImage = document.createElement("img")
bigImage.onload = function () {
image.src = this.src
}
setTimeout(function () {
bigImage.src = "img/large.jpg";
}, 50)
.header-image {
padding: 200px 100px;
background-color: #eee;
background-size: cover;
height: 75vh;
}
<img id="image" class="header-image" src="img/small.jpg" width="1200" />