MathJax not working if loaded from local js file or if the source code is included
Asked Answered
T

2

13

I am testing the MathJax javascript library in a local HTML file. It works and correctly renders math formulas if I include:

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

in the HTML file, but it doesn't work if I include instead:

script type="text/javascript" src="/path_to/mathjax.js"

or even if I put the entire javascript source code. What is the reason? I need to load mathjax.js from local js file into a local HTML file, so the first way doesn't help me. (EDIT- I see an error: failed to load /extensions/MathZoom.js)

Thach answered 6/10, 2013 at 11:48 Comment(1)
Note from the future: cdn.mathjax.org is nearing its end-of-life, check mathjax.org/cdn-shutting-down for migration tips.Architectonic
T
12

I had to load the entire MathJax distribution (17 Mb zip file), expand it and put the right configuration string in the HTML file. The final form is: script type='text/javascript' src='/path_to/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML,local/local'

Thach answered 6/10, 2013 at 13:36 Comment(1)
See this MathJax Documentation Page for details about how to reduce the MathJax installation for use locally.Oina
E
5

This may occur due to two reasons

1.You may have not extracted the entire zip folder, so first do that.

Still you are getting the error look into second reason.

2.You are not referring to the file correctly. eg:

<script type ="text/javascript" src="pathto\mathjax.js">

You have typed an incorrect filename. Correct name of file is MathJax.js.Given below is the correct way.

<script type ="text/javascript" src="pathto\MathJax.js">

MathJax.js is the name of the file in the extracted folder(unless modified)

If all of this is not working,then link to the script in this way:

<script type="text/javascript" src="Pathto\MathJax.js?config=TeX-AMS-MML_HTMLorMML">

The reason that your script is not working is you are not including:

'?config=TeX-AMS-MML_HTMLorMML'

Embowed answered 1/4, 2016 at 11:26 Comment(3)
Thanks, it works for me but i face another problem(I use a repeater to show a list of mathematic phrase) in first page it works normally but when you change repeater page MathJax not work and show a simple text.Perla
@AliAmini, make sure the repeater page u mentioned has the mathjax script.Also check your browser console to check for errors.Embowed
thanks for answer, i solved it by adding MathJax.Hub.TypeSet() in repeater page change event(MathJax.Hub.TypeSet() this will run agian MathJax in page)Perla

© 2022 - 2024 — McMap. All rights reserved.