Loading HTML
by akmiecik
HTML
<div id="page">
<h1>TLorem Ipsum passage</h1>
<p>Lorem ipsum dolor sit amet, on proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div id="loader"></div>
CSS
#page {
display: none;
}
#loader {
display: block;
position: absolute;
top: 0;
left: 0;
z-index: 100;
width: 100vw;
height: 100vh;
background-color: rgba(192, 192, 192, 0.5);
background-image: url("https://theapp.asphaltunlimitedllc.com/wp-content/themes/asphalt/asphalt loader V5.svg");
background-repeat: no-repeat;
background-position: center;
}
JavaScript
function onReady(callback) {
var intervalID = window.setInterval(checkReady, 3000);
function checkReady() {
if (document.getElementsByTagName('body')[0] !== undefined) {
window.clearInterval(intervalID);
callback.call(this);
}
}
}
function show(id, value) {
document.getElementById(id).style.display = value ? 'block' : 'none';
}
onReady(function () {
show('page', true);
show('loader', false);
});