JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://pastebin.com/raw.php?i=Xb8ZLyDp&dummy=.js"></script>
<p id="onemoment"></p>
<div id="main">
</div>
<div id="container"></div>
JavaScript
jQuery(function($) {
var loops = [];
fill();
$("#onemoment").replaceWith('<button id="theButton">Click Me</button>');
$("#theButton").click(function() {
var start = new Date(),
elapsed,
average;
$("#container").html("Destroyed");
loops[loops.length] = elapsed = new Date() - start;
average = 0;
loops.forEach(function(entry) {
average += entry;
});
average = average / loops.length;
display("Elapsed: " + elapsed + "ms, average = " + average.toFixed(2) + "ms");
fill();
});
$("#container").on("jqdestroy", function() {
display("container saw jqdestroy");
});
function fill() {
var n, markup;
markup = [];
for (n = 10000; n > 0; --n) {
markup[markup.length] = "<div " + (n % 2 == 0 ? "class=hook" : "") + "></div>";
}
$("#container").html(markup.join(""));
$(".hook").on("click", function() {
display("clicked");
});
$(".hook").eq(2000).on("jqdestroy", function() {
display("element destroyed");
});
}
function display(msg) {
$("<p>").html(String(msg)).appendTo("#main");
}
});