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

253
Vistas
Why does a script at the end of the body block the page from loading?

If I add an alert in the page head the alert shows up normally and after clicking on OK the website loads, but when I move the alert into the end of the body element the webpage (according to YT videos) should load immediately but it doesn't. It still waiting on me on clicking "OK".

So where I did mistake?

<body>
  <div id="contact-us">
    <h2>Contact Us</h2>
    <p>You can contact Mr Green in various ways ...</p>
    <div class="contact-method">
      <h3>By Phone</h3>
      <p>222-222-FISH</p>
    </div>
    <div class="contact-method">
      <h3>By Email</h3>
      <p>iammrgreen@green.com</p>
    </div>
    <div class="contact-method">
      <h3>By carrier pidgeon</h3>
      <p>To do this, order your podgeon at www.mrgreenspidgeonemporium.com</p>
    </div>
  </div>

  <a href="#top">Go to top</a>

  <script>
    alert("Yo Ninja, welcome to my website!");
  </script>
</body>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can do an experiment for example with setTimeout.

In this snippet if the timeout is too small the alert will appear before anything is painted on the screen, slightly bigger and the whole screen gets painted before the alert appears. It doesn't happen in bits.

<body>
  <div id="contact-us">
    <h2>Contact Us</h2>
    <p>You can contact Mr Green in various ways ...</p>
    <div class="contact-method">
      <h3>By Phone</h3>
      <p>222-222-FISH</p>
    </div>
    <div class="contact-method">
      <h3>By Email</h3>
      <p>iammrgreen@green.com</p>
    </div>
    <div class="contact-method">
      <h3>By carrier pidgeon</h3>
      <p>To do this, order your podgeon at www.mrgreenspidgeonemporium.com</p>
    </div>
  </div>

  <a href="#top">Go to top</a>
  <script>


function afterwait() {
  alert("Yo Ninja, welcome to my website!");
}
setTimeout(afterwait, 10);
</script>
</body>
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