Data lookup vs Style lookup
JavaScript performance comparison
Info
Sometimes you need to do a lot of style lookups. Can you see benefits from caching results in data.
Preparation code
<span style="display: block; " data-touched="false">
Virgin
</span>
<script>
Benchmark.prototype.setup = function() {
var span = document.getElementsByTagName('span')[0];
};
</script>
Preparation code output
Virgin
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Style lookup inline |
|
pending… |
Style lookup inherited |
|
pending… |
Data lookup valid |
|
pending… |
Data lookup getAttribute |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments