Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda