className vs setAttribute vs classList

10 months ago
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36
Test name Executions per second
className 5485.8 Ops/sec
setAttribute 3260.1 Ops/sec
classList 3490.8 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests:
  • className

  • setAttribute

  • classList

Open this result on MeasureThat.net