textContent vs nodeValue vs createTextNode
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var s = document.createElement("span");
var s2 = document.createElement("span");
s2.textContent = " ";
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
textContent |
|
pending… |
createTextNode |
|
pending… |
textContent2 |
|
pending… |
nodeValue |
|
pending… |
createTextNode2 |
|
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
- Revision 2: published by CoolCmd
- Revision 3: published by CoolCmd
0 comments