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

127
Visualizações
HTML JavaScript Script Tag

Why are javascript <script> tags placed in the <body> rather than the other script tags which are usually placed in the <head>?

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

0

  1. JavaScript is blocking; it is often desirable prioritise rendering HTML over loading of JS.
  2. JavaScript often needs to access elements in the DOM during its initial execution (e.g. to add event listeners). Those elements need to exist before the JS can access them. Placing the <script> element after the elements it needs to access is one way to achieve this.

The introduction of the defer attribute allows both these benefits to be gained while leaving the <script> element in the <head> which also allows the HTTP request for the JS to run in parallel. Not everybody has caught up with this development.

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