From my understanding, you need a loader to appear on the page until the corresponding page is completely loaded.
For this here is the solution:
Add the following HTML after the opening tag. This loader div will show a loading image on page load.
<div class="loader"></div>
Use the following CSS to display a loading image on loader div, make loading image position center of the page, and cover the entire screen with a transparent white background.
.loader {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: url('images/pageLoader.gif') 50% 50% no-repeat rgb(249,249,249);
opacity: .8;
}
At first include the jQuery library.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript">
$(window).load(function() {$(".loader").fadeOut("slow");});
</script>
Also, ensure that the entire JavaScript code has been placed under the tag.