Sorry friends what happens is that I have a question with javascript I have a pre-loader and I would like to know how I could make that pre-loader appear only once, what I mean is that the user at the moment of being navigating through the tabs the pre-loader is not appearing every time you change the tab, it loads only once when it is the first time the page is opened I am new in javascript and I do not know how to solve it here I leave the code
<div id="loader"></div>
<div id="content">
<h1>GIF Pre-Loader</h1>
</div>
<script type="text/javascript">
var loader;
function loadNow(opacity) {
if(opacity <= 0) {
displayContent();
}
else {
loader.style.opacity = opacity;
window.setTimeout(function() {
loadNow(opacity - 0.05)
}, 100);
}
}
function displayContent() {
loader.style.display = 'none';
document.getElementById('content').style.display = 'block';
}
document.addEventListener("DOMContentLoaded", function() {
loader = document.getElementById('loader');
loadNow(1);
});
</script>
Help please