Anki Forums

Use KaTeX instead of MathJax

Anki as well as AnkiDroid use MathJax to render latex maths. In my, as well as others experience, MathJax is extremely slow, some of my cards with maths on them (And not a lot, just like one fraction) took about 5 seconds to load on mobile. KaTeX is a lot faster, I have integrated it in one of my card templates and those cads now take less than a second to load, and I think a lot of that time is actually spent on loading the js file. The code for this template is needlessly complicated, a lot of it is for downloading the js file.

Changing the behaviour of anki to use KaTeX instead of MathJax would get rid of all of those problems.

Is there any reason MathJax is used over KaTeX, like missing features in KaTeX, or would there be any interest in switching to KaTeX?

1 Like

MathJax 3 is reasonably fast. 5 seconds sounds excessive, and may be because you’re downloading the libraries from the internet on each card display, due to the fact that AnkiDroid reloads the webview for every card.

Is MathJax not included with AnkiDroid? I had a brief look at the desktop clients source and if I remember correctly the MathJax.js file was included locally.

My info was out of date - it appears it has been in AnkiDroid for a while. I am still surprised it’s taking 5 seconds to load though, and I’d recommend you follow this up on the AnkiDroid issue tracker.