innerHTML vs replaceChildren vs remove by while vs removeChild by while vs remove by forEachFastest: remove by while (18.6x faster)
22,930,084 ops/sec
19,834,692 ops/sec
2,393,814 ops/sec
2,393,814 ops/sec
2,393,814 ops/sec
2,393,814 ops/sec
2,393,814 ops/sec
2,393,814 ops/sec
2,393,814 ops/sec
1,947,324 ops/sec
1,232,103 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| innerHTML | |
| replaceChildren | |
| remove by while | |
| removeChild by while | |
| remove by forEach |
| Test name | Executions per second |
|---|---|
| ✓ remove by while | 22,930,084 Ops/sec |
| removeChild by while | 19,834,692 Ops/sec |
| innerHTML | 2,393,814 Ops/sec |
| replaceChildren | 1,947,324 Ops/sec |
| remove by forEach | 1,232,103 Ops/sec |