Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
setAttribute vs Object.assign
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0
Browser:
Firefox 129
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
setAttribute
694K/s
Object.assign
637K/s
setAttributes
632K/s
View exact numbers
Test name
Executions per second
✓
setAttribute
694,225 Ops/sec
Object.assign
636,644 Ops/sec
setAttributes
631,669 Ops/sec
Tests:
setAttribute
var input = document.createElement("input"); input.setAttribute("class", "my-class"); input.setAttribute("type", "checkbox");
Object.assign
const input = document.createElement("input"); Object.assign(input, {class: 'my-class', type: 'checkbox'});
setAttributes
function setAttributes(el, attrs) {Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key]))} const input = document.createElement("input"); setAttributes(input, {class: 'my-class', type: 'checkbox'});