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

142
Vistas
How many repaints of the DOM will appending children in a for loop cause?

How many repaints of the DOM will appending children in a for loop cause?

I was under the impression this would cause 200. 1 for each time an element is appended, and 1 every time its textContent is updated.

But, in Jake Archibald's talk at JSConf, he seems to mention that browsers will batch this together.

for (let i = 0; i < 100; i++){ 
  const div = document.createElement('div');
  document.body.appendChild(div);
  div.textContent = 'Hello';
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Only once; see Erin Zimmer's continuation on the rendering pipeline https://youtu.be/u1kqx6AenYw

Also, you may test it with something like:

//document.body.innerHTML = '';
for (let i = 0; i < 100; i++){ 
  const div = document.createElement('div');
  document.body.appendChild(div);
  div.textContent = 'Hello';
  let x = 0;
  for(let j = 0; j < 1e7; j++){
     x += Math.sin(Math.random())
  }
}```
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