HTML Preparation code:
AخA
 
1
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js'></script>
2
<form action="" class="js-form">
3
  <fieldset>
4
    <div>
5
      <label><input type="radio" name="s"/></label>
6
      <label><input type="radio" name="s"/></label>
7
      <label><input type="radio" name="s"/></label>
8
      <label><input type="radio" name="s"/></label>
9
      <label><input type="radio" name="s"/></label>
10
      <label><input type="radio" name="s"/></label>
11
    </div>
12
  </fieldset>
13
</form>
Tests:
  • vanilla

    x
     
    var customForms = document.querySelectorAll(".js-form");
    var customFormLabels;
    var customFormLabelSiblings;
    for (var customForm of customForms) {
      customFormLabels = customForm.querySelectorAll("label");
      for (var label of customFormLabels) {
        label.addEventListener("click", function(e) {
          customFormLabelSiblings = this.parentNode.querySelectorAll("label");
          e.preventDefault();
          for (var sibling of customFormLabelSiblings) {
            sibling.classList.remove("is-active");
          }
          this.classList.add("is-active");
        });
      }
    }
  • jQuery

     
    $(".js-form input").on("click", function() {
      $(this).parent().siblings().removeClass("is-active");
      $(this).parent().addClass("is-active");
    })
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    vanilla
    jQuery

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36
Chrome 88 on Windows
View result in a separate tab
Test name Executions per second
vanilla 580.9 Ops/sec
jQuery 65139.5 Ops/sec