Guest User

jshelp

a guest
Oct 28th, 2025
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Find ye section:
  2.  
  3.     <script>
  4.         // añade un preloader a body
  5.         window.addEventListener('load', () => {
  6.         const body = document.querySelector('body');
  7.         body.classList.add('loaded');
  8.         });
  9.     </script>
  10.  
  11. replace with:
  12.  
  13.     <script>
  14.         // añade un preloader a body con un minimo de tiempo :))
  15.         const startTime = Date.now();
  16.         const minLoadTime = 3000; // tiempo minimo en milisegundos (3000 = 3 segundos)
  17.        
  18.         window.addEventListener('load', () => {
  19.             const elapsedTime = Date.now() - startTime;
  20.             const remainingTime = Math.max(0, minLoadTime - elapsedTime);
  21.            
  22.             setTimeout(() => {
  23.                 const body = document.querySelector('body');
  24.                 body.classList.add('loaded');
  25.             }, remainingTime);
  26.         });
  27.     </script>
Tags: Code js
Advertisement
Add Comment
Please, Sign In to add comment