DomParser (v2)

Revision 2 of this benchmark created on


Setup

const parser = new DOMParser();

function strip(html)
{
   var tmp = document.createElement("DIV");
   tmp.innerHTML = html;
   return tmp.textContent || tmp.innerText || "";
}

const dompurify = await import('https://esm.sh/dompurify')

Test runner

Ready to run.

Testing in
TestOps/sec
DomParser
parser.parseFromString('lol <h1>Test</h1>', "text/html").body.textContent
ready
Regex
'lol <h1>Test</h1>'.replace(/<\/?[^>]+>/g, '')
ready
Temp div
strip('lol <h1>Test</h1>')
ready
Dompurify
dompurify.default.sanitize('lol <h1>Test</h1>', {USE_PROFILES: {html: false}})
ready

Revisions

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