Parse HTML and Generate DocumentFragment

Benchmark created on


Preparation HTML




        
        

Setup

const html = '<div>This is a div<div>with a nested div in it</div></div>';

const range = document.createRange();

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
const template = document.createElement('template');

template.innerHTML = html;
const output = template.content;
ready
insertAdjacentHTML (beforeend)
const div = document.createElement('div');

div.insertAdjacentHTML('beforeend', html);
range.selectNodeContents(div);
const output = range.extractContents();
ready
createContextualFragment
const output = range.createContextualFragment(html);
ready
insertAdjacentHTML (afterbegin)
const div = document.createElement('div');

div.insertAdjacentHTML('afterbegin', html);
range.selectNodeContents(div);
const output = range.extractContents();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.