Parse HTML and Generate DocumentFragment (v2)

Revision 2 of this benchmark created on


Preparation HTML




        
        

Setup

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

const div = document.createElement('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)
div.insertAdjacentHTML('beforeend', html);
range.selectNodeContents(div);
const output = range.extractContents();
ready
createContextualFragment
const output = range.createContextualFragment(html);
ready
insertAdjacentHTML (afterbegin)
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.