shim for firefox innertext

JavaScript performance comparison

Test case created by Josh Vermaire

Info

shim for firefox innertext

Preparation code

<span></span>
<script>
Benchmark.prototype.setup = function() {
    span = document.getElementsByTagName('span')[0]
    ff = /Firefox/.test(navigator.userAgent)
    innerText = ff ? function(el, text) {
      return el.textContent = text;
    } : function(el, text) {
      return el.innerText = text;
    };
   
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
innerText
innerText(span, 'hi')
pending…
element.innerText
span.innerText = 'hi'
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

1 comment

Josh Vermaire (revision owner) commented :

Of course, Firefox isn't supporting innerText (thus the reason for this). Although it has the method on each element, which is why it's shown as blazing fast.

Add a comment