I was playing around with jQuery's .text() and .html() methods and running some simple jsPerf tests, when I was startled to discover that .html() is nearly a magnitude faster at retrieving text:
$div.text()– 88,496 ops/sec$div.html()– 592,028 ops/sec
Why is .text() so much slower than .html() when the result is the same? What operations does .text() perform that .html() skips to account for such a difference?
I know that each method has a different purpose; I am curious about the case where they are used for the same purpose.