Skip to content Skip to sidebar Skip to footer

My Jsperf Test Case "breaks" While Evaluating Toggle() With Callback

While testing my answer to Adding HTML5 hidden attribute support to jQuery .toggle() method, I created a JSPerf test to determine how much slower .toggle(function() \[...\]) would

Solution 1:

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.

Post a Comment for "My Jsperf Test Case "breaks" While Evaluating Toggle() With Callback"