Attr(data) vs .data
JavaScript performance comparison
Info
Test which is better, attr('data-name') or .data('name')
Preparation code
</div><script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div data-name="Corey"></div>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
attr |
|
pending… |
data |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments