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

169
Vistas
appending element before executing time consuming function doesnt work; element gets inserted when function finished

I have a function doing some calculations that takes about 2-3 seconds. While that fuction runs, I want to display a loader onto the page, until the function finishes. However, the loader gets inserted to the page not until the function finished. The function inserts a canvas that shows the results once it finished, maybe thats causing a problem? Because when I replace that function with a setTimeout, I dont have any problems. I also replaced it with a function that logs "HI" 10000 times, but I get the same effect as with setTimeout; the loader displays correctly. Used code:

var header = document.querySelector(".header");

var loader = document.createElement("div");
loader.className = "loader";

header.append(loader);
 
var master = new CalculatingMaster();
master.calculateAndDisplayResults();
about 4 years ago · Juan Pablo Isaza
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