Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
style.display = none vs. classList add hide
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0
Browser:
Firefox 130
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
style.display = none
551.8 Ops/sec
classList add hide
918.2 Ops/sec
HTML Preparation code:
<style type="text/css"> .hide { display: none; } </style> <div id="foo"></div>
Tests:
style.display = none
var element = document.getElementById("foo"); var i = 3000; while (i--) { element.style.display = 'none'; element.style.display = 'block'; }
classList add hide
var element = document.getElementById("foo"); var i = 3000; while (i--) { element.classList.add("hide"); element.classList.remove("hide"); }