I.e.
$('button').click(function() {
$('#myElement').toggle(function() { alert("called") })
})
The callback function you pass to toggle
only gets executed after the toggle action completes. In other words, it’s an asynchronous action, so if you want to measure how long it takes until the callback is fired, use jsPerf’s async/defer feature.