Trim vs Test

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Trim
for (const element of document.querySelectorAll('*')) {
  const text = element?.textContent;
  if (text == null) {
  	return true;
  }
  return text.trim() === '';
}
ready
Regex Test
const re = /\S/;

for (const element of document.querySelectorAll('*')) {
  const text = element?.textContent;
  if (text == null) {
  	return true;
  }
  return !re.test(text);
}
ready

Revisions

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