Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
Preload heavy gif image

I have a heavy process that requires several seconds to complete.

That's why I've added an animated loading page to make the wait acceptable.

<style>
   .modal_gif {
      display:    none;
      position:   fixed;
      z-index:    1000;
      top:        0;
      left:       0;
         height:     100%;
         width:      100%;
         background: rgba( 255, 255, 255, .8 ) 
         url('static/loading.gif') 
         50% 50% 
         no-repeat;
         background-size: 80%, auto;
        }
    body.loading .modal_gif {
         overflow: hidden;   
         }
         body.loading .modal_gif {
         display: block;
         }
        
 </style>
<script>
       $(document).on({
          ajaxStart: function() { $body.addClass("loading");    },
          ajaxStop: function() { $body.removeClass("loading"); }    
    });
</script>

However, the gif weigh about 1MB and it is not displayed after the first request: there is only a semi-transparent veil on the screen.

The second and following requests are working well, which makes me think that it is a gif loading problem.

I'd like the animated loading gif to be always displayed when requested, even for the first request.

Do you know how to preload a gif animated file as hidden and display it even for the first request?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can try preloading it using a dummy img tag (with visibility hidden, not display none). If we're at it, you can in the first place:

.modal_gif {
  visibility: hidden;
  display: block;
  pointer-events: none;
}

body.loading .modal_gif {
  visibility: visible;
  overflow: hidden;
}

or even play with opacity 0 or opacity 1, the key here is pointer-events: none; so the image is clickable through.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda