className vs setAttribute vs classList

26 days ago
User agent: Mozilla/5.0 (Linux; Android 7.0; MI-CH-82S) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.92 Mobile Safari/537.36
Test name Executions per second
className 267.0 Ops/sec
setAttribute 182.0 Ops/sec
classList 190.3 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests:
  • className

  • setAttribute

  • classList

Open this result on MeasureThat.net