Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0
Firefox 122
Windows
Desktop
2 years ago
Benchmark.js
String literally
807.0M/s
String based (return struct)
3.1M/s
String based (if-else struct)
3.1M/s
Entries, filter, map, join
2.8M/s
clsx
2.5M/s
Array based
1.6M/s
classnames
1.5M/s
Recursive tagged template literal
907K/s
View exact numbers
Test name Executions per second
String literally 807,010,944 Ops/sec
String based (return struct) 3,117,498 Ops/sec
String based (if-else struct) 3,061,914 Ops/sec
Entries, filter, map, join 2,823,878 Ops/sec
clsx 2,495,638 Ops/sec
Array based 1,627,120 Ops/sec
classnames 1,521,329 Ops/sec
Recursive tagged template literal 906,619 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: