jQuery .data for mutiple keys and read all at once (v23)

Revision 23 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<input type="text" id="theInput" value="foo" data-test1="test1" data-test2="test2"
data-test3="test3">
</input>
<script>
  var theInput = $('#theInput');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
mutiple keys
// async test
var t1 = theInput.data('test1');
var t2 = theInput.data('test2');
var t3 = theInput.data('test3');
ready
all at once
// async test
var data = theInput.data();
var t1 = data['test1'];
var t2 = data['test2'];
var t3 = data['test3'];
ready
direct at once
// async test
var data = $.data(theInput);
var t1 = data['test1'];
var t2 = data['test2'];
var t3 = data['test3'];
ready

Revisions

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