Jquery.data() window or document container
JavaScript performance comparison
Info
Compares use of JQuery $.data() when storing data in window vs document vs cached element.
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
$('#foobar').data('foodata','bar - 123');
$(window).data('windata','bar - 123');
$(document).data('docdata','bar - 123');
</script>
<div id="foobar"></div>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
window .data() |
|
pending… |
document data() |
|
pending… |
div element data() - $this |
|
pending… |
div element data() |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments