With createElement() and append() vs With createElement() and appendChild() vs With innerHTML and getElementById() vs With innerHTML and getElementsByClassName() vs With innerHTML and getElementsByTagName() vs With innerHTML and querySelector() vs With innerHTML and querySelectorAll() vs With createElement() and outerHTML vs With innerHTML and children[children.length - 1] vs With innerHTML and lastChild vs With innerHTML and lastElementChild vs With createElement() and innerHTML| Test case name | Result |
|---|---|
| With createElement() and append() | |
| With createElement() and appendChild() | |
| With innerHTML and getElementById() | |
| With innerHTML and getElementsByClassName() | |
| With innerHTML and getElementsByTagName() | |
| With innerHTML and querySelector() | |
| With innerHTML and querySelectorAll() | |
| With createElement() and outerHTML | |
| With innerHTML and children[children.length - 1] | |
| With innerHTML and lastChild | |
| With innerHTML and lastElementChild | |
| With createElement() and innerHTML |
| Test name | Executions per second |
|---|---|
| ✓ With innerHTML and getElementById() | 80,814 Ops/sec |
| With innerHTML and lastChild | 80,355 Ops/sec |
| With innerHTML and lastElementChild | 77,864 Ops/sec |
| With innerHTML and getElementsByTagName() | 77,459 Ops/sec |
| With innerHTML and querySelector() | 77,210 Ops/sec |
| With innerHTML and getElementsByClassName() | 74,097 Ops/sec |
| With innerHTML and children[children.length - 1] | 69,530 Ops/sec |
| With innerHTML and querySelectorAll() | 68,396 Ops/sec |
| With createElement() and innerHTML | 68,205 Ops/sec |
| With createElement() and outerHTML | 66,977 Ops/sec |
| With createElement() and append() | 1,275 Ops/sec |
| With createElement() and appendChild() | 559 Ops/sec |