I found that MathJax is extremely slow. Is there a better, lighter and faster Javascript library that can render mathematical notation equally well?

  • 9
    $\begingroup$ It may be your browser that is slow. What browser and version are you using? Have you tried using Chrome or Firefox? $\endgroup$ Aug 30, 2010 at 15:03
  • $\begingroup$ @Bill, I am using Chrome, latest dev build. $\endgroup$
    – Graviton
    Sep 2, 2010 at 14:37
  • 5
    $\begingroup$ I agree that it's very slow. I often see the LaTeX formatted text as the page is being Typeset by MathJax. I'm using Chrome 12, Ubuntu 11.04, and a fast computer, and the performance even for a single equation on an empty page is quite poor. $\endgroup$
    – slacy
    May 25, 2011 at 23:54
  • 2
    $\begingroup$ @Graviton Huh? MathJax slow? Maybe you encountered a page entirely filled with math formulas, which MathJax will take time compiling it. $\endgroup$
    – user93957
    Nov 3, 2013 at 15:38
  • 1
    $\begingroup$ Since some feel it more important to engage in useless debate and downvote actual concrete answers to the question, I guess I'll post this as a comment: See meta.math.stackexchange.com/questions/16809/… and khan.github.io/KaTeX $\endgroup$
    – Jeff Ward
    Jun 27, 2016 at 22:10
  • 3
    $\begingroup$ @JeffWard While the written question is indeed "is there a faster alternative", the obvious implicit context is "that we can use on math.SE". People were telling you in the comments that it had already been discussed here and found not satisfactory. This isn't a general software recommendation Q&A website, this is a website to discuss what happens on math.SE, in case you hadn't noticed. $\endgroup$ Jun 28, 2016 at 7:51
  • 10
    $\begingroup$ I'm voting to close this question as off-topic because it is not current anymore. If somebody wishes to revisit this matter I feel it is better to make a new start. $\endgroup$
    – quid Mod
    Jun 28, 2016 at 9:29
  • 1
    $\begingroup$ @quid: Thank you. $\endgroup$
    – Asaf Karagila Mod
    Jun 28, 2016 at 21:32
  • 2
    $\begingroup$ Not sure if this is relevant anymore, but Mathjax has a 1 second delay when doing transforms. You can speed this up by setting MathJax.Hub.processSectionDelay = 0 $\endgroup$
    – Matt
    Aug 19, 2016 at 13:43
  • $\begingroup$ @Matt what's the purpose of that delay and what do we lose by setting that variable to 0? $\endgroup$ Jun 28, 2021 at 20:33
  • $\begingroup$ @NikeDattani From what I recall (sorry, this was 5 years ago already), Mathjax had the 1 second delay built-in. I think it's there to allow for the browser to first get the page layout/styling figured out first before Mathjax starts processing. $\endgroup$
    – Matt
    Jul 2, 2021 at 14:19
  • $\begingroup$ @Matt I see! If that's the case, then it seems totally unnecessary. I would think the browser should be able to get the page layout figured out within far less than a second, even on a computer 5 (or even 15) years ago, which I would think would be capable of doing more than 1 MFLOP (million floating-point operations per second), and therefore would presumably be able to read thousands of lines of HTML/CSS/JavaScript/PHP/etc. and process it within a few milli-seconds. How do we lobby for MathJax.Hub.processSectionDelay to be set to 0 by default in the next version? $\endgroup$ Jul 2, 2021 at 18:19

2 Answers 2


Mathjax performance depends on several factors, like:

  • the browser you use
  • the hardware in your computer
  • your internet connection/latency

If you want to improve the performance of mathjax, you think of a couple of things:

  1. Use a better computer. I did a short test, and if run a page with much mathjax at my 5 year old laptop, it takes around 4 times longer, then if I run the page at my newest computer.

  2. Download local fonts. There are two options. You can either download the STIX fonts locally, or download the TeX fonts locally. For the TeX fonts, download mathjax 2.2 from this page: http://www.mathjax.org/download/. Once downloaded, go to this map: fonts\HTML-CSS\TeX\otf and install all the fonts in this map. If you prefer the look of the STIX fonts, you can download them from here: http://www.stixfonts.org/

  3. Use Firefox in combination with MathML rendering I just found this out, and I'm amazed by how much faster MathML rendering is compared with HTML-CSS rendering. This only works in firefox. You can turn the MathML rendering on by right clicking on a math formula:
    Math Settings -> Math Renderer -> MathML

Here is more information about MathML rendering:

The NativeMML output processor uses the browser’s internal MathML support (if any) to render the mathematics. Currently, Firefox has native support for MathML, and IE has the MathPlayer plugin for rendering MathML. Opera has some built-in support for MathML that works well with simple equations, but fails with more complex formulas, so we don’t recommend using the NativeMML output processor with Opera. Safari has some support for MathML since version 5.1, but the quality is not as high as either Firefox’s implementation or IE with MathPlayer. Chrome, Konqueror, and most other browsers don’t support MathML natively, but this may change in the future, since MathML is part of the HTML5 specification.

The advantage of the NativeMML output Processor is its speed, since native MathML support is much faster than using complicated HTML and CSS to typeset mathematics, as the HTML-CSS output processor does. The disadvantage is that you are dependent on the browser’s MathML implementation for your rendering, and these vary in quality of output and completeness of implementation. MathJax relies on features that are not available in some renderers (for example, Firefox’s MathML support does not implement the features needed for labeled equations). The results using the NativeMML output processor may have spacing or other rendering problems that are outside of MathJax’s control.

(from http://docs.mathjax.org/en/latest/output.html)

  • 2
    $\begingroup$ I tried FF's MathML renderer, and it introduces vertical whitespace above and below maths expressions. This makes any use of inline maths very ugly. But I have to concur -- it's fast. $\endgroup$
    – Lord_Farin
    Nov 2, 2013 at 20:45

I don't think it is MathJax that is the problem, but rather the nature of the way web pages are formatted. MathJax has to generate a bunch of div and span blocks, which takes time for a browser to render. While we're writing posts, these get (re)rendered all the time.

The solution to this problem might be implementation of one or more of the feature requests:

  1. Make a better SE parser of what formulas need rerendering, so that MathJax has less rerendering to do.
    I expect this to be very hard to implement, and would probably be buggy.

  2. Make a delay in rendering, as it is with the syntax highlighting.
    In other words, formulas get displayed as a source ($formula$), until the poster has stopped typing for a short period of time, let's say 3 or 5 seconds. After such a delay, post's formulas would get rendered as we're used to.

  3. Add a "Don't process formulas while I'm typing" checkbox.
    This would go either somewhere near the post-writing area, or in the profile (or, preferably, both, with the one in the profile being the default state), and could mean either "don't process at all" or "behave as I've described in the item 2 above".

  4. Some kind of delay as described in 2 and, implicitly, in 3, but with the delay time growing with the post size (up to a limit of, IMO, no more than 30 seconds).
    This way, shorter posts (which are not troublesome) would not be affected, while the longer ones would be so hard on our computers. I leave the definition of "length" here opened. It might be the number of characters, which implements trivially, but could also be the number of formulas (which in itself takes some parsing).
    I think that this (as well as, maybe, item 3) would warrant a "Process now" button to do a single rendering when the poster requests it, so that (s)he doesn't have to wait unnecessarily.

The way things are now, I type my longer posts in gvim, and then copy/paste them here. It's not ideal, but for me it is an acceptable workaround.

  • 2
    $\begingroup$ I perceive that MathJax performance has improved over the time since the Question was originally posed, but there are a lot of variables to try and account for. To me the speed is adequate for me, running Chrome on Windows 7 or a Linux platform. On Editing existing Answers, there is a Hide Preview option (fine print at left between the Answer box and the Preview window), so it might be simple to give that on initial Answers (although this place is now used for "draft saved" indiciations). $\endgroup$
    – hardmath
    Nov 2, 2013 at 17:18
  • $\begingroup$ I knew I saw it somewhere, but I couldn't remember where! Thank you. As for the speed, I had a hard time and I had to switch to gvim when I was writing this answer. Usually, it's not as much of a problem, but it would still be better if the site was more friendly towards slower computers. $\endgroup$ Nov 2, 2013 at 18:46
  • $\begingroup$ Point 1 would probably be fairly simple to do - just cache the generated DOM object mapped from the TeX. The problem then is keeping memory usage under control. But this is probably something which doesn't help much in most contexts in which MathJax is used: I suspect that MSE is unusual in using it in a continuous edit mode. $\endgroup$ Nov 2, 2013 at 23:27
  • 1
    $\begingroup$ @PeterTaylor MathJax actually has quite a decent support for rerendering. What I see as a problem in point 1 is how to determine what in the post to rerender. That would have to include some LaTeX parsing by the MSE before invoking MathJax renderer, because formulas don't go just in $...$ and $$...$$. Maybe rerendering just the edited paragraph would be sufficient, given that formulas cannot include empty lines. $\endgroup$ Nov 3, 2013 at 2:07

Not the answer you're looking for? Browse other questions tagged .