Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!