JSFiddle - React, Tailwind, and code Playground
HTML
<div id="element"></div>
CSS
#element {
background-image: url(https://i.imgur.com/rkhEnrb.png);
height: 100vh;
}
JavaScript
var element_backgroundimage = $('#element').css('background-image'),
image_value = element_backgroundimage.replace('url(', '').replace(')', '').replace(/\"/gi, ''),
$img = $('<img src="' + image_value + '" />');
$img
.one('load', function() {
console.log("loaded");
})
.filter(function() { // If the image is already loaded, call the load function
if (this.complete) {
$img.load();
}
});