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

Revision 24 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
var t1 = theInput.data('test1');
var t2 = theInput.data('test2');
var t3 = theInput.data('test3');
ready
all at once
var data = theInput.data();
var t1 = data['test1'];
var t2 = data['test2'];
var t3 = data['test3'];
ready
direct at once
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.