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

123
Vistas
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 Respuestas
Responde la pregunta

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 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