Hey there,
I'm currently working on implementing a page preloader following the tutorial provided in the link. However, I seem to be encountering an issue with the JavaScript portion as my preloader disappears quickly while the rest of the page continues loading.
I suspect that the presence of the "no-js" class in the HTML might be causing this problem.
Here's the tutorial I've been using
<!doctype html>
<html class="no-js animated fadeIn" lang="EN">
<head>
</head>
<body>
<div class="loader hidden">
<img src="../mirror/img/logo/LOGO_Loadscreen.gif" alt="loading logo">
</div>
<header>
</header>
<main class="black-background">
</main>
<script src="js/vendor/modernizr-3.5.0.min.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-3.2.1.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<script>
document.documentElement.className =
document.documentElement.className.replace("no-js","js");
</script>
<!-- Google Analytics: change UA-XXXXX-Y to be your site's ID. -->
<script>
window.ga=function(){ga.q.push(arguments)};ga.q=[];ga.l=+new Date;
ga('create','UA-XXXXX-Y','auto');ga('send','pageview')
</script>
<script src="https://www.google-analytics.com/analytics.js" async defer></script>
<script type="text/javascript">
window.addEventListener("load", function () {
const loader = document.querySelector(".loader");
console.log(loader);
loader.className += " hidden"; // class "loader hidden"
});
</script>
</body>
.loader {
position: fixed;
z-index: 12000;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: var(--light-color);
display: flex;
justify-content: center;
align-items: center;
}
.loader > img {
width: 80px;
}
.loader.hidden {
animation: fadeOut 1s;
animation-fill-mode: forwards;
}
@keyframes fadeOut {
100% {
opacity: 0;
visibility: hidden;
}
}