styleͰͷมߋΛආ͚Δ
• DOMͷมߋճΛ1ճʹ
·ͱΊΔ
• display: noneͰӅ͠มߋ(n
ճ)ͤ͞displayΛ͢ (nճ
ͷreflow/repaintʹର͠ɺ
͜ͷํ๏ͩͱ2ճͰࡁΉ)
// js
const el = document.body;
const style = el.style;
// bad
style.left = '10px'; // reflow, repaint
style.top = '20px'; // reflow, repaint
// good
el.classList.add("anotherclass"); // reflow, repaint
// .css
.anotherclass {
left: 10px;
top: 20px;
}