Regex vs DOMParser

Benchmark created on


Setup

const title = '<div><p><strong>text</strong>more text</p></div>'
const parser = new DOMParser();

Test runner

Ready to run.

Testing in
TestOps/sec
Regex
title.replace(/<[^>]*>/g, '').trim().length
ready
DOM Parser
parser.parseFromString(title, "text/html").body.textContent.trim().length
ready

Revisions

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