Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
window.getComputedStyle vs. className vs. classList 2
(version: 0)
Comparing performance of:
getComputedStyle vs className vs classList vs getComputedStyle cached
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id="foo"></div>
Tests:
getComputedStyle
var i = 3000; while (i--) { window.getComputedStyle(document.body).getPropertyValue("display").indexOf('none') !== -1 }
className
var i = 3000; while (i--) { document.body.className.includes('hide'); }
classList
var i = 3000; while (i--) { document.body.classList.contains('hide'); }
getComputedStyle cached
var i = 3000; const styles = window.getComputedStyle(document.body); while (i--) { styles.getPropertyValue("display").includes('none'); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
getComputedStyle
className
classList
getComputedStyle cached
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
jquery.css vs getComputedStyle
jquery3.4.1.css vs getComputedStyle
window.getComputedStyle (no props requested) vs. classList.contains
window.getComputedStyle vs. className vs. classList
Comments
Confirm delete:
Do you really want to delete benchmark?