Concepts
Grouped geometry reads and style writes
An application pattern that separates independent geometry reads from subsequent writes. It is not a built-in API or a guaranteed performance improvement.
Formal Syntax & Structure
javascript syntaxjavascript
const widths = nodes.map(read); nodes.forEach(write)Working Example
Example Snippetjavascript
(async () => {const nodes=[20,40].map(w=>{const el=document.createElement("div");el.style.width=w+"px";document.body.append(el);return el;});const widths=nodes.map(el=>el.getBoundingClientRect().width);nodes.forEach((el,i)=>el.style.width=(widths[i]+5)+"px");console.log(JSON.stringify(nodes.map(el=>el.getBoundingClientRect().width)));nodes.forEach(el=>el.remove());})()