Remove attr composed vs chained simple methods

JavaScript performance comparison

Revision 2 of this test case created by John Bender

Preparation code

<script src="https://code.jquery.com/jquery-1.7.2.js"></script>
<script src="https://raw.github.com/johnbender/jquery-lazy-proxy/master/lazy.js"></script>
<script>
window.testElementCount = 20;
</script>
<script src="https://raw.github.com/johnbender/jquery-lazy-proxy/master/test/proxies-perf.js"></script>

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

};
</script>

Preparation code output

<script src="https://raw.github.com/johnbender/jquery-lazy-proxy/master/lazy.js"></script> <script> window.testElementCount = 20; </script> <script src="https://raw.github.com/johnbender/jquery-lazy-proxy/master/test/proxies-perf.js"></script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Vanilla chain with two $.fn.removeAttr
window.testSetDivs.removeAttr( "foo" ).removeAttr( "bing" );
pending…
Composition of two $.removeAttr
window.testSetDivs.cleanUpJustAttrs( "foo", "bing" );
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments