`clsx` vs `cn`

Benchmark created on


Preparation HTML

<script type="module">
import clsx from 'https://unpkg.com/clsx@2.1.1/dist/clsx.mjs'
import { twMerge } from 'https://unpkg.com/tailwind-merge@2.6.0/dist/bundle-mjs.mjs'

window.clsx = clsx
window.twMerge = twMerge
</script>

Setup

function cn (...inputs) {
  return twMerge(clsx(inputs))
}

Test runner

Ready to run.

Testing in
TestOps/sec
clsx
const style = clsx('one', 'two')

console.log(style)
ready
cn
const style = cn('one', 'two')

console.log(style)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.