Nice CSS only spinner "Waitig for page load"
layout:
<div class="overlay" style="display: none;"> <div class="spinner" id="spinner"></div> </div> <script> // Spinner document.addEventListener("DOMContentLoaded", function () { const elements = document.querySelector(".big_button"); // Too many false positives? //const elements = document.querySelector("a, input[type=submit]"); const overlay = document.querySelector(".overlay"); if (elements) { elements.addEventListener("click", function () { // event.preventDefault(); // event.stopImmediatePropagation(); setTimeout(function () { overlay.style.display = "flex"; }, 750); }); } }); </script>
css:
/* Spinner */ .overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.3); display: flex; justify-content: center; align-items: center; z-index: 9999; } .spinner { border: 10px solid white; border-top: 10px solid #ef7f01; border-radius: 50%; width: 50px; height: 50px; animation: spin 1.5s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }