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

117
Visualizações
What makes a source script not loading and then loading again?

When using a <script> tag with src attribute one should expect it to download:

<script src="https://unpkg.com/neovis.js@2.0.0-alpha.9/dist/neovis.js"></script>

However recently it fails to download, and I fail to locate the reason why it becomes so. The possibly reliable fix is that when that happens, I change it to:

<script>
function cdnLoaded() {
    console.log('loaded');
}
function cdnError() {
    console.log('not loaded');
    // do error handling here
}
</script>    
<script onload="cdnLoaded()" onerror="cdnError()" async src="https://unpkg.com/neovis.js@2.0.0-alpha.9/dist/neovis.js"></script>

At this point, the console says it's loaded but actually it's not. But after that when I revert it back to:

<script src="https://unpkg.com/neovis.js@2.0.0-alpha.9/dist/neovis.js"></script>

then it works again. This has happened twice in two browsers (Edge and Firefox), and I haven't had a chance to test it again.

What can be the reason for this strange behavior? Could this be a kind of caching?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Browser cache scripts by filename. Probably adding/removing onload and onerror properties force the browser to download the script again.

To force file reload you could apply a versioning

<script src="util.js?v=1"></script>

Modern frameworks use to join, minify and rename script file automatically. You can do it with tools like webpack

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