Remove no-js - Regex vs. String Replace

Benchmark created by Joe Watkins on


Description

Using JavaScript to remove hardcoded no-js class on html element.

Preparation HTML

<html class="no-js">

Test runner

Ready to run.

Testing in
TestOps/sec
Regex
document.documentElement.className = document.documentElement.className.replace(/\bno-js\b/,'js');
ready
String
document.documentElement.className = document.documentElement.className.replace("no-js","js");
ready

Revisions

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

  • Revision 1: published by Joe Watkins on
  • Revision 2: published by Joe Watkins on
  • Revision 3: published by Joe Watkins on