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

200
Visualizações
Variables lost with DOMContentLoaded my page logic was destroyed

I'm trying to fire some frontend project with several JS script files attached to have page logic working properly. At first all links to the scripts were placed at the end of my body section and it was working OK. But after I decided to use DOMContentLoaded events listener so that I could place links to the scripts in my header section. However right after that some of my scripts stopped to work. After quick checking it appeared that the culprit was that some scripts share some variables that was defined as global so all scripts had access to it, but right then these variables got in the DOMContentLoaded callback code blocks {...}, obviously other scripts lost access to all of them.

Of course, I can go backward now and put all scripts links at the end of the body or use defer or async attributes, but I'm just wonder if there a way to still use DOMContentLoaded but nevertheless have variables enclosed in DOMContentLoaded callback got available globally and shared among all page scripts ?

about 4 years ago · Juan Pablo Isaza
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