back

by raphlinus·7y ago·view on hn ↗
A huge amount of the speed problem in MathJax is just the default configuration, which does the math typesetting in a deferred callback and throttles the work, basically guaranteeing that the browser will go through a full relayout and repaint many times if there are lots of math on the page. It's possible to change this, but I don't think many people do.

Another reminder of the power of defaults.

2 comments
My limited understanding of MathJax is that it uses the browser to measure glyphs. KaTeX on the other hand includes metrics for many of its glyphs. Where things get a little tricky is i18n. There are many languages which our current fonts don't cover and thus we have no metrics for them (we make some educated guess about some unicode ranges). It would be really nice if browsers implemented a Font Metrics API, unfortunately efforts to do so appear stalled at the moment.
Can you please elaborate a bit more on that? How can you configure it to be faster? I'm considering leaving MathJax for pre-rendered png because it is unusably slow (with the default configuration at least). My use case is a whole book of math on a single html page. Pdf viewers have no problem with that. Yet, firefox+mathjax cannot cope.
Yes, you want to set processSectionDelay to 0. Here's an example: https://github.com/raphlinus/ghilbert/blob/master/src/htmlou...
I have been using MathJax since before it was called MathJax (it used to be jsMath), and I've never found any synchronous rendering option to speed it up. You can minimize the page updates by not showing anything until mathjax is done, but that is disturbing to users (who either see nothing for an unknown amount of time, or see raw latex formulas), and it's frankly not much faster in my testing. If there really is such a MathJax option to synchronously render faster, then this page [1] should in fairness mention it.

[1] https://www.intmath.com/cg5/katex-mathjax-comparison.php