Preloader Code on Every Page

Hi everyone,

I have created more than 100 websites for my clients and I am having trouble with the preloader code I added to the sites now.

The code I have used for 1 year was working properly on every page. About a few weeks ago I noticed that the preloader code doesn’t work on every page on my clients’ sites. But I haven’t seen a problem with my own sites. Today, when I look at my sites, the code does not work on every page too, it only works once when the site is opened.

It is very strange that the code worked properly a few days ago and now only works on the first page. You can view the code below:

<div id="preloader">

</div>

<script type="text/javascript">
  (
 function() {
 var preload = document.getElementById("preloader");
 var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
 var loading = 0;
 var id = setInterval(frame, 64);

 function frame() {
 if (loading == 30) {
          clearInterval(id);
         preload.style.display = "none";
        } else {
          loading = loading + 1;
 if (!isMobile) {
 if (loading == 10) {
              document.getElementById("preloader").classList.add('hidden');
              }
          } else if (isMobile)

          {
 if (loading == 14) {
              document.getElementById("preloader").classList.add('hidden');
                }
          }
        }
      }
    })();

</script>

<style>
  #preloader {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 999;
    overflow: visible;
    background: #FEFCFE url('GIF URL') no-repeat center center;
    display: block;
    opacity: 1;
    transition: 1s opacity ease-in;
  }

  #preloader.hidden {
    opacity: 0;
  }

</style>

A must-have feature for my customers and the sites I created is not working now, and it was a very good solution for long loading problems. Can you help me? I am looking forward to your help to talk to people who encounter the same problem or to solve this problem together.

I want to be sure that I understand. The following option is described in the documentation :

Reload on every page
Tracking code is loaded again after every page navigation. This option forces your code to reload every time the user navigates to a new page.

Is this the option that you are using?

If this is the case, let me know and I will report this to QA for evaluation.

1 Like

@yisrael-wix

Hi,

First of all thank you for your interest and understanding.

Wix Corvid is currently rolling out a new performance update. I had no problem about loading the preloader on every new page for any website I created. I think these sites have received this update and there is a problem about Tracking & Tools section because on the New Improvement about Corvid Announcement topic, someone had the same problem as me and the Wix Team solved the problem.

I also wrote on the announcement topic about my problem. I have 2 websites of my own that are important for now. These preloaders need to be fixed because that’s our job.

Websites: www.konutdiyari. com / www.konutdiyariestates. com

Thanks in advance for your help.

@isabel-z Hey Caroline, I just took a look and it appears that this might be related to the new performance release. Related in two ways: the performance might be so fast that the the preloader does not appear, or that there’s an issue with executing the embedded scripts in tracking/analytics.

Give me minute. I want to change the configuration of your two sites and I’ll be right back.

OK - I changed the configuration of your sites. Please try again. You might first need to count to 100.

Where is this option in my site?

Created mine, feel free to use, may not be displayed over the widgets

<!DOCTYPE html>
<html>
<head>
    <style>
        /* Preloader Styles */
        #preloader {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 9999;
            background: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .loader {
            border: 5px solid #f3f3f3;
            border-top: 5px solid #3498db;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            animation: spin 2s linear infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <div id="preloader">
        <div class="loader"></div>
    </div>

    <script>
        // Function to show the preloader
        function showPreloader() {
            document.getElementById("preloader").style.display = "flex";
        }

        // Function to hide the preloader
        function hidePreloader() {
            document.getElementById("preloader").style.display = "none";
        }

        // Show preloader when a new page starts loading
        window.addEventListener('beforeunload', showPreloader);

        // Hide preloader when the page is fully loaded
        window.addEventListener('load', hidePreloader);
    </script>
</body>
</html>

Where to add this code? My developer tools option does not have the code option
Screenshot 2024-02-15 115142

Look at —> SETTINGS