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

127
Vistas
Does setting margin value cause layout thrashing

I recently came across a layout thrashing issue and wanted to confirm if my understanding is correct.

What I was doing

Let element = document.getElememtById(id);
Let element2 = document.getElementById(id2);
element.style.margin = element2.style.margin

This code was causing the layout thrashing as I was getting the margin value of element2 in my js code (which requires layout calculation) and then setting another element's margin value which makes previous layout invalid.

I am not calculating the margin value for element2 now and storing it in some variable, the code now looks like

Let element2 = document.getElementById(id2);
element.style.margin = variable

Does setting the margin here lead to layout thrashing or is that acceptable?

about 4 years ago · Santiago Gelvez
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