jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Comparing performance of $.data and $().data in jQuery 1.4.2 and 1.4.3.
It appears:
$(el).data() is still much slower than $.data()
fetching data with both $.data() and $(el).data() in 1.4.3 can be slower than in 1.4.2
fetching HTML5 data attributes in 1.4.3 with $(el).data() can be slower than fetching non-HTML5 data attributes
setting data with $(el).data() is faster in 1.4.3 than in 1.4.2
setting data with $.data() is slower in 1.4.3 than in 1.4.2
<div data-pop="fizz"></div>
<script src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<script>
var jQuery142 = $.noConflict();
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script>
var jQuery143 = $.noConflict();
</script>
<script>
var el142 = jQuery142('div'),
el143 = jQuery143('div');
el142.data('bang', 'boom');
el143.data('bang', 'boom');
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
1.4.2 set $(el).data() |
| ready |
1.4.3 set $(el).data() |
| ready |
1.4.2 set $.data() |
| ready |
1.4.3 set $.data() |
| ready |
Fetch data with 1.4.2 and $(el).data() |
| ready |
Fetch data with 1.4.3 and $(el).data() |
| ready |
Fetch data with 1.4.2 and $.data() |
| ready |
Fetch data with 1.4.3 and $.data() |
| ready |
Removed |
| ready |
Fetch data attr with 1.4.3 and $(el).data() |
| ready |
Removed |
| ready |
Fetch data attr with jQuery 1.4.3 and $.data() |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.