Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0
Firefox 95
Windows
Desktop
3 years ago
Test name Executions per second
Vanilla JS 164973.8 Ops/sec
jQuery 23589.9 Ops/sec
HTML Preparation code:
AخA
 
1
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
2
<div class="fuck">
3
  <div class="shit">
4
    <div class="fart">
5
      <div class="hell">
6
        <div class="shitty">
7
          <div class="hella">
8
            <div class="farta">
9
              <div class="meow">
10
                <div class="spag">
11
                  <div class="hetti">
12
                    <div class="wtfm8">
13
                      <div class="ysomanyclassesyo">
14
                        deeply buried
15
                      </div>
16
                    </div>
17
                  </div>
18
                </div>
19
              </div>
20
            </div>
21
          </div>
22
        </div>
23
      </div>
24
    </div>
25
  </div>
26
</div>
27
<div class="fuck">
28
  <div class="shit">
29
    <div class="fart">
30
      <div class="hell">
31
        <div class="shitty">
32
          <div class="hella">
33
            <div class="farta">
34
              <div class="meow">
35
                <div class="spag">
36
                  <div class="hetti">
37
                    <div class="wtfm8">
38
                      <div class="ysomanyclassesyo">
39
                        deeply buried
40
                      </div>
41
                    </div>
42
                  </div>
43
                </div>
44
              </div>
45
            </div>
46
          </div>
47
        </div>
48
      </div>
49
    </div>
50
  </div>
51
</div>
52
<div class="fuck">
53
  <div class="shit">
54
    <div class="fart">
55
      <div class="hell">
56
        <div class="shitty">
57
          <div class="hella">
58
            <div class="farta">
59
              <div class="meow">
60
                <div class="spag">
61
                  <div class="hetti">
62
                    <div class="wtfm8">
63
                      <div class="ysomanyclassesyo">
64
                        deeply buried
65
                      </div>
66
                    </div>
67
                  </div>
68
                </div>
69
              </div>
70
            </div>
71
          </div>
72
        </div>
73
      </div>
74
    </div>
75
  </div>
76
</div>
77
<div class="fuck">
78
  <div class="shit">
79
    <div class="fart">
80
      <div class="hell">
81
        <div class="shitty">
82
          <div class="hella">
83
            <div class="farta">
84
              <div class="meow">
85
                <div class="spag">
86
                  <div class="hetti">
87
                    <div class="wtfm8">
88
                      <div class="ysomanyclassesyo">
89
                        deeply buried
90
                      </div>
91
                    </div>
92
                  </div>
93
                </div>
94
              </div>
95
            </div>
96
          </div>
97
        </div>
98
      </div>
99
    </div>
100
  </div>
101
</div>
102
<div class="fuck">
103
  <div class="shit">
104
    <div class="fart">
105
      <div class="hell">
106
        <div class="shitty">
107
          <div class="hella">
108
            <div class="farta">
109
              <div class="meow">
110
                <div class="spag">
111
                  <div class="hetti">
112
                    <div class="wtfm8">
113
                      <div class="ysomanyclassesyo">
114
                        deeply buried
115
                      </div>
116
                    </div>
117
                  </div>
118
                </div>
119
              </div>
120
            </div>
121
          </div>
122
        </div>
123
      </div>
124
    </div>
125
  </div>
126
</div>
Tests:
  • Vanilla JS

     
    document.querySelectorAll('.ysomanyclassesyo').forEach(e => e.closest('.fuck').classList.add('fuckster') );
  • jQuery

     
    $('.ysomanyclassesyo').parents('.fuck').addClass('fuckster');