I want to use preloader for my webpage. The current preloader is not loading right after any click on the links that I have on my page. The existing page is seen and after sometime (just few seconds before the loading of a new page) the preloader works and the new page is visible. I want my preloader to work immediately once I refresh or click any links on the web page.
#loading{
position: fixed;
width: 100%;
height: 100vh;
background: #fff
url('https://static-steelkiwi-dev.s3.amazonaws.com/media/filer_public/2b/3b/2b3b2d3a-437b-4e0a-99cc-d837b5177baf/7d707b62-bb0c-4828-8376-59c624b2937b.gif')
no-repeat center center;
z-index: 99999;
}
<!DOCTYPE html>
<html>
<head>
{% load static %}
<link rel="stylesheet" href="{% static '/styles1.css' %}">
</head>
<body onload="myFunction()" class="hold-transition skin-green sidebar-collapse sidebar-mini fixed">
<div id="loading"></div>
...
...
<script>
var preloader = document.getElementById("loading");
function myFunction(){
preloader.style.display = 'none';
};
</script>
</body>
</html>
Please help to sort out this
Thanks