1

I would like to use MathJax within my website, and I have opted to use a CDN method. MathJax.org states that you can put

<script 
   src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML'>
</script>

within the HTML <head></head> tags and provided a pre-populated example on jsbin

However, I have noticed when using MathJax within WordPress, the MathJax documentation suggests using

<script type="text/javascript"
   src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

I have noticed, that the difference is in the main part of the src address where the CDN used is cdn.mathjax.org instead of cdnjs.cloudflare.com, and the address points to mathjax/latest/MathJax.js instead of mathjax/2.7.2/MathJax.js.

I have put the second script into the jsbin example to see if there is a difference in function, and the example still works. Is it preferable (or more correct) to use the second script over the first one whether using WordPress or not, with the understanding that the second one will point to the most up-to-date version of MathJax?

Chris Rogers
  • 370
  • 3
  • 22
  • Please note that: https://www.mathjax.org/cdn-shutting-down/ also: https://docs.mathjax.org/en/latest/start.html *"We retired our self-hosted CDN at cdn.mathjax.org in April, 2017. We recommend using cdnjs.com which uses the same provider."* – Bob__ Mar 15 '18 at 13:44
  • I have just seen something to that effect and looking more into this. – Chris Rogers Mar 15 '18 at 13:45
  • The link to the documentation in your post points to the v1.1 documentation -- which is 6 years old. – Peter Krautzberger Mar 15 '18 at 15:02
  • This question is also usefulfor adding the correct option for pandoc, when convertung LaTeX to HTML with MathJax. Thank you for the question. – Maxim Aug 18 '22 at 03:56

1 Answers1

1

As @Bob__ pointed out, and I had just read prior to then, MathJax was shutting down its CDN and they actually

retired cdn.mathjax.org in April, 2017.
(Source: docs.mathjax.org)

The same webpage states that there are many free CDN providers that provide copies of MathJax. Some provide “rolling releases”, i.e., links that update to the latest available version upon release, and cdnjs.com is recommended. This matches Mathjax.org's page at https://www.mathjax.org/cdn-shutting-down/

They say

To jump start using cdnjs, you accomplish the first step by putting

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

into the <head> block of your document

Note: the configuration file TeX-MML-AM_CHTML is a great way test all input options at once. You can find leaner combined configuration packages in MathJax documentation.

Interestingly, before seeing that, carrying out a MathJax libraries search on cdnjs.com provides an updated script tag of

<script
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/MathJax.js">
</script>

So the answer is to check for the latest library script tag in cdnjs.com, which is currently for version 2.7.3 and use that one. Currently

<script
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/MathJax.js">
</script>

and if you wish to use the TeX-MML-AM_CHTML configuration file, use:

<script
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
Chris Rogers
  • 370
  • 3
  • 22
  • This answer could be improved by clarifying “carrying out a MathJax libraries search on cdnjs.com provides a... script tag of...”. When I search cdnjs for “MathJax”, I see about 30 libraries and have no idea how to differentiate them. If “latest” refers to the version number, then there is no one “latest library script tag in cdnjs.com”. All 30 have the same version number. Maybe“latest” means “most recently updated”, but I see no way to determine that. – randy May 12 '21 at 21:12
  • I have also the same problem as @randy. I do not know which one should be use, e.g there is any `MathJax.js` in version 3.2.2. – dudung May 14 '23 at 00:15