Remove no-js - Regex vs. String Replace (v3)

Revision 3 of this benchmark created by Joe Watkins on


Description

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

Preparation HTML

<div id="target" class="no-js"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
Regex
var target = document.getElementById("target");
                target.className = target.className.replace(/\bno-js\b/,'js');
ready
String
 
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