clientWidth / clientHeight vs offsetWidth / offsetHeight vs getBoundingClientRectFastest: getBoundingClientRect (1.4x faster)
1,183,218 ops/sec
885,658 ops/sec
854,855 ops/sec
Fastest: clientWidth / clientHeight (2.7x faster)
11,051,065 ops/sec
8,499,202 ops/sec
4,148,978 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| clientWidth / clientHeight | |
| offsetWidth / offsetHeight | |
| getBoundingClientRect |
| Test name | Executions per second |
|---|---|
| ✓ clientWidth / clientHeight | 24,148,986 Ops/sec |
| offsetWidth / offsetHeight | 15,425,046 Ops/sec |
| getBoundingClientRect | 9,283,536 Ops/sec |