Code is simple but page gets load along with loader.
<script>
$(window).load(function() {
$(".loader").delay(2000).fadeOut("slow");
})
</script>
<body>
<header>
<div class="loader"><img src="img/loader.gif"></div>
</header>
</body>
Code is simple but page gets load along with loader.
<script>
$(window).load(function() {
$(".loader").delay(2000).fadeOut("slow");
})
</script>
<body>
<header>
<div class="loader"><img src="img/loader.gif"></div>
</header>
</body>
<body>
<header>
<div class="loader"><img src="img/loader.gif"></div>
<script>
$(".loader").fadeOut("slow");
</script>
</header>
</body>
Should make it show the loader immediately after it's rendered, and then slowly fade out. This <header>
section and then the script should be the first items in the <body>
.
Prefer using document.ready
like below.
$(document).ready(function() {
$(".loader").delay(2000).fadeOut("slow");
})
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<header><div class="loader"><img src="img/loader.gif" alt="loading............."/></div> </header>