dotnotation vs setAttribute

Benchmark created on


Preparation HTML

<div id="test">
</div>

Setup

var el = document.getElementById('test');

Teardown

el.removeAttribute('class');

Test runner

Ready to run.

Testing in
TestOps/sec
dotnotation
for (let i = 0; i < 100; i++) {
	el.class = 'foo';
	el.class = 'bar';
}
ready
setAttribute
for (let i = 0; i < 100; i++) {
	el.setAttribute('class', 'foo');
	el.setAttribute('class', 'bar');
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.