You could try something like this with CSS animations
var myVar;
function myFunction() {
document.getElementById("loader").style.display = "block";
document.getElementById("myDiv").style.display = "none";
myVar = setTimeout(showPage, 3000);
}
function showPage() {
document.getElementById("loader").style.display = "none";
document.getElementById("myDiv").style.display = "block";
}
/* Center the loader */
#loader {
position: absolute;
display: none;
left: 50%;
top: 50%;
z-index: 1;
width: 100px;
height: 100px;
margin: -50px 0 0 -50px;
border: 10px solid #3498db;
border-radius: 50%;
border-top: 10px solid #f3f3f3;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#myDiv {
display: none;
text-align: center;
}
<a onclick="myFunction()" href="#" target="_self">Download</a>
<div id="loader"></div>
<div style="display:none;" id="myDiv" class="animate-bottom">
<h2>Tada!</h2>
<p>Some text in my newly loaded page..</p>
</div>