DomParser

Benchmark created on


Setup

const parser = new DOMParser();

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

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

Revisions

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