AsciiMath with version independent MathJax snippet (post v4)

2 views
Skip to first unread message

Isaac Demme

unread,
Apr 9, 2026, 2:09:03 PM (8 days ago) Apr 9
to MathJax Users
What is the simplest way to use a version-independent script like the one recommended on https://www.mathjax.org/#gettingstarted but also keep AsciiMath support?

This is the snippet we are currently using across our website:

<!--MathJax-->
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

While this is working, it is specifying version 2.7.5.
Our website has quite a bit of Asciimath as well as TeX and some MathML so I really need support for all three, but I'd also like to future-proof the website as much as possible and not need to  update code snippets when a new version of MathJax comes out.

Any suggestions?
---Isaac

Davide Cervone

unread,
Apr 10, 2026, 10:55:18 AM (7 days ago) Apr 10
to mathja...@googlegroups.com
What is the simplest way to use a version-independent script like the one recommended on https://www.mathjax.org/#gettingstarted but also keep AsciiMath support?

You could use

<script>
MathJax = { loader: { load: ['input/asciimath'] } };
</script>

This does specify version 4, but will get whatever the latest version 4 release is.  You could remove the "@4" to get the latest release of whatever major version is the current one, but I would not recommend that, as major releases can include breaking changes, so sticking with the major version is usually a good idea.  

Our website has quite a bit of Asciimath as well as TeX and some MathML so I really need support for all three, but I'd also like to future-proof the website as much as possible and not need to  update code snippets when a new version of MathJax comes out.

As I mention above, you probably want to stick with a major version (but get automatic updates within that version).  The way that MathJax is packaged can change with the major version, as it did between v2 and v3, so there is no guarantee that v5 will have tex-mml-chtml.js, or that the configuration options will be the same.  Major versions can change such things.

One thing that you could use to help make it easier to update in the future would be to make a file called mathjax.js or some such thing that contains

window.MathJax = { loader: { load: ['input/asciimath'] } };
const script = document.createElement('script');
document.head.appendChild(script);

and then load that file into the pages where you want to use MathJax rather than loading MathJax directly.  That way there is only one file to be fixed when you need to update MathJax.

Davide

Reply all
Reply to author
Forward
0 new messages