KaTeX vs MathJax

JavaScript performance comparison

Revision 42 of this test case created by xymostech

Preparation code

<link href="//cdn.rawgit.com/Khan/KaTeX/v0.5.1/dist/katex.min.css" rel="stylesheet" type="text/css">
<script src="//cdn.rawgit.com/Khan/KaTeX/v0.5.1/dist/katex.min.js"></script>
<script src="https://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js?delayStartupUntil=configured"></script>

<script>
MathJax.Hub.Config({
  jax: ["input/TeX", "output/HTML-CSS"],
  extensions: [],
  TeX: {
    extensions: ["AMSmath.js", "AMSsymbols.js", "noErrors.js", "noUndefined.js"]
  },
  "HTML-CSS": {
    showMathMenu: false,
  },
  messageStyle: "none"
});
MathJax.Hub.Configured();
</script>

<div id="math"></div>
      
<script>
Benchmark.prototype.setup = function() {
  var math = document.getElementById("math");
  var formula = "\\dfrac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}";

};

Benchmark.prototype.teardown = function() {
  math.innerHTML = "";

};
</script>

Preparation code output

<link href="//cdn.rawgit.com/Khan/KaTeX/v0.5.1/dist/katex.min.css" rel="stylesheet" type="text/css"> <script src="https://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js?delayStartupUntil=configured"></script> <script> MathJax.Hub.Config({ jax: ["input/TeX", "output/HTML-CSS"], extensions: [], TeX: { extensions: ["AMSmath.js", "AMSsymbols.js", "noErrors.js", "noUndefined.js"] }, "HTML-CSS": { showMathMenu: false, }, messageStyle: "none" }); MathJax.Hub.Configured(); </script> <div id="math"></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
KaTeX
katex.render(formula, math);
math.outerWidth;
pending…
MathJax
// async test
math.innerHTML = "<script type='math/tex'>" + formula + "</script>";
MathJax.Hub.Queue(["Process", MathJax.Hub, math]);
MathJax.Hub.Queue(function() {
  math.outerWidth;
  deferred.resolve();
});
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.

0 Comments