CSS Style - Case 2
JavaScript performance comparison
Preparation code
<div id="foo">
Bar
</div>
<style>
.my-style { background-color: red; width: 200px; }
</style>
<script>
Benchmark.prototype.setup = function() {
var foo = document.getElementById('foo');
};
Benchmark.prototype.teardown = function() {
foo.style.cssText = foo.className = '';
};
</script>
Preparation code output
Bar
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
foo.style.* |
|
pending… |
foo.style.cssText |
|
pending… |
foo.className |
|
pending… |
foo.classList |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Cong Liu
- Revision 2: published by Cong Liu
- Revision 3: published by Cong Liu
0 comments