Is there a way to make MathJax 4.0 run faster?

24 views
Skip to first unread message

Andrew Murdza

unread,
Aug 7, 2025, 2:49:35 PMAug 7
to MathJax Users
MathJax 4.0 is running noticeably slower for me than MathJax 3.2. I'm wondering if there is a way to disable some of the additional features that are slowly things down a lot.

Davide Cervone

unread,
Aug 7, 2025, 7:48:23 PMAug 7
to mathja...@googlegroups.com
Andrew:

Again, there is not enough information here to give you a reasonable answer.   You have not made any indication of your use case.  For example, is this just the initial page rendering, or are you calling MathJax's API?  If the latter, what functions are you calling?  As before, what is you configuration?  Do you have a pair of test pages that you can link to that shows your v3 and v4 experiences?

In terms of the features, the most expensive one is the speech generation, but that is now in a web-worker, so it should not affect the rendering speed (unless you are calling the promise-based API calls by hand, which do wait for that to finish before they resolve).  You can disable that using the Mathjax contextual menu by unchecking "Semantic Enrichment" in the "Options" sub-menu and see if that is the source of your complaint.

The line-breaking is another potential reduction in performance, but it is not on by default, and you haven't said if you have enabled that.  You can check the "Math Settings" sub-menu's "Wide Expressions" sub-menu to see which approach to wide expressions is being used.  "Overflow" is the default and is what was in effect for v3.

Another potential source of delay is access to the MathJax fonts and their data.  In v3, since there was only one font, its data was bundled with the combined components like tex-chtml.js, but in v4, the fonts have much greater coverage, so they are broken into smaller pieces, and some expressions may require loading of additional files to get the data for the characters used.  That means network access, and that can be a delay.  The "mathjax-tex" font (the font used in v3) is the only one that isn't broken into smaller pieces, but if you select it, the font does have to be loaded, so that is still an additional file that has to be obtained over the network.  You don't say what font or what component you are loading, so it is hard to tell if this may be an issue.  Note that if you are loading an alternative font, you may want to use a component that ends in "-nofont" so that you don't have to load the default font's data and then your own font's data as well.  There are versions of tex-mml-chtml.js and tex-mml-svg.js that include the various fonts in the font packages themselves, so you could load https://cdn.jsdelivr.net/npm/@mathjax/mathjax-tex-font/tex-mml-chtml-mathjax-tex.js instead of https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js with font: 'mathjax-tex' specified, for example.

Those are the main things that you can adjust.

Davide


On Aug 7, 2025, at 2:49 PM, Andrew Murdza <andrew...@gmail.com> wrote:

MathJax 4.0 is running noticeably slower for me than MathJax 3.2. I'm wondering if there is a way to disable some of the additional features that are slowly things down a lot.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mathjax-users/7a3a60b6-b54f-4b3e-b769-e7105c4d3c2bn%40googlegroups.com.

Davide Cervone

unread,
Aug 8, 2025, 6:53:08 AMAug 8
to MathJax Users
Oh, I forgot to mention:  if you have a page with lots of math you might consider the lazy-typesetting extension.  This was available in v3 as well.
Reply all
Reply to author
Forward
0 new messages