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

138
Vistas
Why console.log shows me that there are 0 loaded images in the html document?

I have been making preloader based on counting images in the html document according to one youtube tutorial.

I got stuck and don't understand why console.log command says that the amount of loaded images is 0, though I have some images in the html document.

I have made the codesandbox so that one could easily see the code: https://codesandbox.io/s/preloader-mip2o?file=/app.js

Thank you for your help!

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

0

It happens, because JavaScript works asynchronously. I've added 1 line to image_loaded function:

function image_loaded() {
  alert("In image_loaded")
  images_loaded_count++;
...

After that I run it in browser and see that console.log is called before images are actually loaded.

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