HTML Preparation code:
AخA
 
1
<div><svg id="target" class="target"></svg></div>
Script Preparation code:
x
 
const target = document.getElementById('target');
var div = document.createElement('DIV');
div.innerHTML = `<svg id="target" class="something new"></svg>`;
var replacement = div.firstChild;
Tests:
  • Set Attribute

     
    var i = 1000;
    while (i--) {
        target.setAttribute('class', 'something new')
    }
  • Replace Element

     
    var i = 1000;
    while (i--) {
        target.parentNode.replaceChild(replacement, target);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Set Attribute
    Replace Element

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 Edg/90.0.818.62
Chrome 90 on Windows
View result in a separate tab
Test name Executions per second
Set Attribute 829.4 Ops/sec
Replace Element 451.9 Ops/sec