Closest attr check and remove attr composed vs chained

JavaScript performance comparison

Test case created by John Bender


This tests the performance of a vanilla chain of jquery mobile's $.fn.enhanceable and $.fn.removeAttr against the performance of a composed version of the underlying functions.

Preparation code

<script src=""></script>
<script src=""></script>
window.testElementCount = 10;
<script src=""></script>
Benchmark.prototype.setup = function() {
    // cache the test sets
    window.testSetDivs = $( "[data-test]" );
    // add the attribute and data to be removed
      .attr("foo", "bar")
      .attr("bing", "bang")
      .data( "baz", "bak" );

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Vanilla chain with $.fn.enhanceable and $.fn.removeAttr
window.testSetDivs.enhanceable().removeAttr( "foo" );
Composition of $.enhanceable and $.removeAttr
window.testSetDivs.enhanceableCleanAttr( "foo" );

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:


Comment form temporarily disabled.

Add a comment