Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Modern dataset vs old .getAttribute() vs jQuery .data() vs jQuery .attr()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
dataset
441828.1 Ops/sec
getAttribute
471112.2 Ops/sec
jQuery .data()
8263.4 Ops/sec
jQuery .attr()
7875.5 Ops/sec
HTML Preparation code:
<h3 id="data" data-test="text">kipr202 header</h3> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
Tests:
dataset
window.onload = function() { document.querySelector("h3#data").dataset.test; }
getAttribute
window.onload = function() { document.querySelector("h3#data").getAttribute("test"); }
jQuery .data()
$(document).ready(function() { $("h3#data").data("test"); });
jQuery .attr()
$(document).ready(function() { $("h3#data").attr("data-test"); });