Khan Academy has released a new library to typeset mathematical notation on webpages, called KaTeX.
“But we already have MathJax!” you say, perhaps a little too enthusiastically. Well, Khan Academy has a lot of pages about maths, and they have a fairly rare set of requirements: the maths they use is relatively simple, they usually have a lot of it on the page, and their users are usually not techy types with zippy computers. For their purposes, MathJax has a couple of big design flaws: it likes to measure the text surrounding each equation very exactly so that its output is pixel-perfect, and it runs asynchronously, so you can see equations popping into existence as it works down the page.
Because of that, they’ve clearly decided it’s worthwhile writing a new library to typeset maths that suits them better than MathJax. KaTeX is much more limited in the kinds of output it supports than MathJax, sticking to inline-style rendering and a much smaller subset of TeX commands. It runs synchronously, which means it exchanges temporarily locking up the browser for taking much less time to finish. Importantly, it doesn’t get held up by asking the browser to take measurements, instead using much faster CSS rules to make sure the output matches surrounding text.
Khan Academy is using KaTeX as a first port of call to render maths, and using MathJax as a fallback for things it can’t render. So it looks like KaTeX really is worth having.
KaTeX very neatly fills its niche, but it’s not a complete replacement for MathJax. I’m sure it’ll come in useful on sites other than Khan Academy, so thanks to them for open-sourcing it.
Note: I did some paid freelance work for MathJax earlier this summer.
KaTeX – a new way to display math on the Web by Murray Bourne