aboutsummaryrefslogtreecommitdiffstats
path: root/speed/closest.html
blob: eacf74935ed47d2bfb138d3c8cdf56b8c19b12cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!doctype html>
<html>
<head>
	<title>Test Event Handling Performance</title>
	<script src="benchmark.js"></script>
	<script src="jquery-basis.js"></script>
	<script>var old = jQuery.noConflict(true);</script>
	<script src="../dist/jquery.js"></script>
  <script>
    jQuery(function ready() {
      var node = $("#child"), name;

      [".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"].forEach(function foreach(item) {
        name = "closest '" + item + "'";
        console.log(name);

        console.log("new", benchmarkString("$('#child').closest('" + item + "')", 5000, name));
        console.log("old", benchmarkString("old('#child').closest('" + item + "')", 5000, name));
      });
    });
	</script>
</head>
<body>
  <div>
    <p>Hello</p>
    <div class="zoo" id="zoo" data-foo="bar">
      <div>
        <p id="child">lorem ipsum</p>
        <p>dolor sit amet</p>
      </div>
    </div>
  </div>
</body>
</html>