Issue with continuous loader malfunction

I integrated a 3-second mini-loading animation on my website. It shows up every time I refresh the site or navigate to another page.


The issue I'm facing is that once I add the loading section, it never stops (it should only last for 3 seconds). Usually, this continuous loading occurs when there's an error in the code, but I can't seem to locate it. I want the loading section to display for just three seconds and then disappear.


Below is the code snippet for the loading section:

*,
*:before,
*:after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
  cursor: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGj0lEQVRYR71Wa2yTVRh+zve13bpvLbCWsbUbu7CBF266wboxVtoqoCwTgv4wKt4TfxiixkRNjImJURKNoiLE+5ygeAmCCQQjAhtjQ6zMdhuo29puA7a5ra7delnb9TPnlNZ1a5cRwfdP+53zXp7znOe85xAAKDPpDTy42lAotNM3Ida2Njb+Tcf/DyO0yLLKynnKVJkzWjAkinVAuPbnn+pPXG8QDAA1ndFgWb9x/XKFUoFTJxowPDwEURR7rjcrMQBlJsNn+QsXblt/x...
<link href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" rel="stylesheet"/>
<!DOCTYPE html>

  <!-- loaders -->
  <div class="loader hidden">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Goodgame_Studios_Logo_2015.svg/250px-Goodgame_Studios_Logo_2015.svg.png" alt="Loading..." />
    <div id="rotator"></div>
  </div>

  <!-- Header -->
  <header class="header">
    <div class="header__content">
      <nav class="menu">
        <ul class="menu__internal">
          <li><a href="" id="Home-page">text</a></li>
          <li><a href="">text</a></li>
          <li><a href="">text</a></li>
        </ul>
      </nav>
    </div>
  </header>

  <!-- Hero -->
  <section class="hero" data-midnight="default">
  </section>

I have commented out the loading section below as compared to before, so you can see what needs fixing.

*,
*:before,
*:after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
  cursor: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGj0lEQVRYR71Wa2yTVRh+zve13bpvLbCWsbUbu7CBF266wboxVtoqoCwTgv4wKt4TfxiixkRNjImJURKNoiLE+5ygeAmCCQQjAhtjQ6zMdhuo29puA7a5ra7delnb9TPnlNZ1a5cRwfdP+53zXp7znOe85xAAKDPpDTy42lAotNM3Ida2Njb+Tcf/DyO0yLLKynnKVJkzWjAkinVAuPbnn+pPXG8QDAA1ndFgWb9x/XKFUoFTJxowPDwEURR7rjcrMQBlJsNn+QsXblt/x... 
<link href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" rel="stylesheet"/>
<!DOCTYPE html>

  <!-- loaders -->
<!--  <div class="loader">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Goodgame_Studios_Logo_2015.svg/250px-Goodgame_Studios_Logo_2015.svg.png" alt="Loading..." />
    <div id="rotator"></div>
  </div> -->

  <!-- Header -->
  <header class="header">
    <div class="header__content">
      <nav class="menu">
        <ul class="menu__internal">
          <li><a href="" id="Home-page">text</a></li>
          <li><a href="">text</a></li>
          <li><a href="">text</a></li>
        </ul>
      </nav>
    </div>
  </header>

  <!-- Hero -->
  <section class="hero" data-midnight="default">
  </section>

Answer №1

Have you experimented with using JQuery in a similar way?

<script>
$(document).ready(function(){
  $(".loader").fadeOut(3000);
})
</script>

This causes the loader to gradually disappear over a 3-second period once the document is fully loaded.

If your website is dynamic, you may want to consider exploring alternative options.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Incorporate a line break between the day and month on your JQuery datepicker

Is it possible to insert a line break or some other element between the day and month in the input field when using JQuery datepicker? Here is the current code I have: jQuery('#checkin').datepicker({ showAnim: "drop", dateFormat ...

What is the reason for seeing "11111111" at the end of the displayed data?

My PHP and Ajax setup successfully retrieves data, but for some reason, after the data is loaded, it is displaying "1111111" at the bottom. I have searched various websites for a solution but haven't been able to find one. Can someone please help me w ...

Enhance Your Highcharts Funnel Presentation with Customized Labels

I am working on creating a guest return funnel that will display the number of guests and the percentage of prior visits for three categories of consumers: 1 Visit, 2 Visits, and 3+ Visits. $(function () { var dataEx = [ ['1 Vis ...

Request to api.upcitemdb.com endpoint encountering CORS issue

This code may seem simple, but for some reason, it's not working as expected. What I'm trying to achieve is to call the GET API at: I want to make this API call using either JavaScript or jQuery. I've attempted various approaches, but none ...

The ul element is not being properly styled by the CSS pseudoclass :checked

I recently attempted to create a responsive navigation bar using a YouTube tutorial that utilizes a checkbox to display and hide the menu on smaller screens. Despite meticulously following the tutorial and testing different browsers such as Chrome, Edge, a ...

Shut down two modal windows and then open one anew

I am facing an issue with fancybox where I need to open 2 modals of a plugin and then close 2 and open 1 again... For example: closing 2 modals and opening 1 modal again... http://jsfiddle.net/g3R75/1/ I have tried the following code but it doesn't ...

Position the second line of text to align in MUI

I am facing an issue with aligning the text on the second line. It should match up with the text on the first line. For reference, you can check out the Codesandbox by CLICKING HERE <Card sx={{ maxWidth: 200 }}> <CardMedia component="i ...

The JavaScript program is occasionally receiving unconventional input

I'm really struggling with this one. As part of a programming exercise, I am developing a JavaScript calculator. You can access the functioning calculator here on Codepen. At the bottom left corner of the calculator interface, you will notice a "+-" ...

Exploring Nested Divs with Vue Test Utils

Recently, I came across this shallowMounted vue component: <div class="card p-relative"> <div class="card-header"> <div class="card-title h4"> a lovely title <!----> <!----> </div> </div ...

The display of the selected input is not appearing when the map function is utilized

I am attempting to use Material UI Select, but it is not functioning as expected. When I use the map function, the default value is not displayed as I would like it to be. However, it does work properly when using the traditional method. *** The Method th ...

Exploring the Differences Between Nth-CSS and Jquery

What are the advantages of using the nth function in CSS instead of applying it through jQuery, especially considering its compatibility with IE? Is it better to simply use jQuery from the start and avoid using it in a stylesheet altogether? Hopefully thi ...

Altering the dimensions of radio buttons

I am a newcomer to using material-ui. I am currently working on incorporating radio buttons in a component and would like to reduce its size. While inspecting it in Chrome, I was able to adjust the width of the svg icon (1em). However, I am unsure how to a ...

Remove underlining from a Custom Link when hovering over it

Is there a way to remove the blue underline from my custom donate button? I created it by going to Appearance -> Menus -> Custom Link. The issue is that this custom link (donate button) is inheriting the same CSS as the navigation menu items, which I want ...

Only JSON objects with a boolean value of true will be returned

I am working on returning JSON objects in JavaScript/TypeScript that have a true boolean value for the "team" property. For example, the JSON data I am using is as follows: { "state": "Texas", "stateId": 1, "team": true }, { "state": "Cali ...

Adjust the size of the div to fit its content while maintaining the transition animation

I am aiming for the DIV height to automatically adjust to the text within it, while also maintaining a minimum height. However, when the user hovers their mouse over the DIV, I want the height to change smoothly without losing the transition effect. When ...

What is the best way to showcase saved HTML content within an HTML page?

I have some HTML data that was saved from a text editor, <p style=\"font-size: 14px;text-align: justify;\"> <a href=\"https://www.xpertdox.com/disease-description/Chronic%20Kidney%20Disease\" style=\"background-color: tr ...

Learn how to dynamically pass a value from a prop to a router-link in Vue.js

I created a custom button component and decided to switch from using <a> tags to <router-link>. However, I encountered an error because the router-link was rendering before the prop received its value. To address this, I added an if statement b ...

What could be causing media queries to not update values even after being changed through JavaScript?

I have a simple navigation bar on my website, featuring links to different subpages. To enhance the user experience on mobile devices, I added a hamburger menu icon that is displayed on smaller screens. The links in the navigation bar are hidden using CSS ...

In HTML, data can be easily accessed, however, JavaScript does not have the same

When trying to access the 'data' element in a JSON object, I have encountered an issue. The element is accessible when called from HTML, but not when called in JavaScript. HTML: <p>{{geoJson.data}}</p> JavaScript: let scope; let d ...

The Access-Control-Allow-Headers in preflight response does not permit the kbn-version request header field

I've configured the Kibana settings in a yml file as shown below: server.cors: true server.cors.origin: "*" server.cors.credentials: true server.cors.methods: "GET, POST, PUT, DELETE, OPTIONS, HEAD" server.cors.headers: "Origin, X-Requested-With, Con ...