Test name | Executions per second |
---|---|
getElementById | 5497740.0 Ops/sec |
querySelector (class) | 4002229.2 Ops/sec |
<div id="testElement" class="testClass"></div>
var el = document.getElementById('testElement');
var className = el.className;
var el = document.querySelector('.testClass');
var className = el.className;