JSFiddle - React, Tailwind, and code Playground
HTML
<div id="some_target"></div>
CSS
#some_target {
position: absolute;
width: 100%; height: 100% ;
}
JavaScript
$(document).ready(function() {
var newImage = "url(http://vanusasousa.com.br/sicom/img/background2.jpg)"; //Image name
$("#some_target").hide() //Hide it
.one('load', function() { //Set something to run when it finishes loading
$(this).fadeIn(); //Fade it in when loaded
})
.css('background', newImage) //Set the source so it begins fetching
.each(function() {
//Cache fix for browsers that don't trigger .load()
if(this.complete) $(this).trigger('load');
});
});