Skip to content

erykpiast/serialize-dom

Repository files navigation

serialize DOM

This project aims to create the DOM serialization function that has the smallest possible impact on the browser and the serialized page.

Performance testing methodology

For every implementation version, we run the function 1 000 000 (one million) times in each browser engine.

The data presented summarizes the time needed to serialize a DOM tree with 1000 elements, 100 times. That's the way of catching subtle differences between different implementations in browsers with reduced timer accuracy (1 run may take less than 1 ms). The test is repeated for 100 different trees, 100 times for each tree, to get repeatable results.

Upper performance boundary

Sole node traversal takes time. Even when we don't save anything in any way, but just visit all nodes and read their attributes, we block the thread for some time.

┌──────────┬──────┬──────┬──────┐
│ (index)  │ p50  │ p95  │ p99  │
├──────────┼──────┼──────┼──────┤
│ firefox  │ 45   │ 46   │ 49   │
│ chromium │ 29.2 │ 30.5 │ 33   │
│ webkit   │ 14   │ 15   │ 16.5 │
└──────────┴──────┴──────┴──────┘

Latest results

The direct strict creation approach gives these results for 100 iterations.

┌──────────┬──────┬──────┬──────┐
│ (index)  │ p50  │ p95  │ p99  │
├──────────┼──────┼──────┼──────┤
│ firefox  │ 71   │ 74   │ 78   │
│ chromium │ 49.1 │ 51.7 │ 58.3 │
│ webkit   │ 22   │ 23   │ 26   │
└──────────┴──────┴──────┴──────┘

About

DOM serialization with minimal website impact

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors