style.setProperty vs style.cssText vs style vs Object.assign vs setAttributeFastest: setAttribute (16.7x faster)
626 ops/sec
45 ops/sec
40 ops/sec
40 ops/sec
37 ops/sec
Fastest: setAttribute (53.4x faster)
454 ops/sec
30 ops/sec
27 ops/sec
9 ops/sec
8 ops/sec
Fastest: setAttribute (29.7x faster)
512 ops/sec
31 ops/sec
30 ops/sec
21 ops/sec
17 ops/sec
Fastest: setAttribute (15.7x faster)
185 ops/sec
18 ops/sec
15 ops/sec
13 ops/sec
12 ops/sec
Fastest: setAttribute (56.3x faster)
2,240 ops/sec
63 ops/sec
61 ops/sec
42 ops/sec
40 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| style.setProperty | |
| style.cssText | |
| style | |
| Object.assign | |
| setAttribute |
| Test name | Executions per second |
|---|---|
| ✓ setAttribute | 1,551 Ops/sec |
| style.setProperty | 82 Ops/sec |
| style.cssText | 81 Ops/sec |
| Object.assign | 77 Ops/sec |
| style | 74 Ops/sec |