Test name | Executions per second |
---|---|
style | 550.2 Ops/sec |
style.cssText | 654.7 Ops/sec |
<div id='a'>foo</div>
<div id='b'>bar</div>
var a = document.getElementById('a');
var b = document.getElementById('b');
const fontSize = 20 * Math.random();
a.style.fontSize = `${fontSize}px`;
a.style.letterSpacing = `-${Math.random()}em`;
a.style.wordSpacing = `${Math.random()}em`;
a.style.lineHeight = `${Math.random()}`;
a.style.textIndent = a.style.fontSize;
const x = a.getBoundingClientRect();
const fontSize = 20 * Math.random();
b.style.cssText = `
font-size: ${fontSize}px;
letter-spacing: -${Math.random()}em;
word-spacing: ${Math.random()}em;
line-height: ${Math.random};
textIndent: ${fontSize}px;
`;
const x = b.getBoundingClientRect();