I want to use MathJax on my application's html ui component, which does not support accessing third-party JavaScript libraries through a CDN.
I want to download the complete code for MathJax, which is available as a .zip file here (https://github.com/mathjax/MathJax-src/releases/tag/3.2.2), and then unzip it to my application directory.
I don't want to use npm to install MathJAx because the application will be distributed to my community so users won't be forced to install MathJax on their computers.
That is, I want my application to be able to render LaTeX equations without the internet, and independently of any 3rd party installation. It would be great if there was a way to call the MathJax library directly from the above available folder in the zip file.
I tried inserting the following basic HTML page in hopes of displaying the user-defined equations provided by my application, but failed:(
<!DOCTYPE html> <html> <head> <title>MathJax Example</title> <script src="MathJax-src-3.2.2\components\src\tex-chtml/tex-chtml.js" id="MathJax-script" async></script> </head> <body> <h1>Equation:</h1> <div id="equation"> $$ y = \frac{{\sin(x^2)}}{{\cos(2x)}} $$ </div> <script> MathJax.Hub.Queue(["Typeset",MathJax.Hub,"equation"]); </script> </body> </html>
Any answer or comment will be very helpful to me..Thank you
I'm trying to make the MathJax library work in my html page without internet or 3rd party installation
P粉7953113212023-09-08 11:59:34
There are several issues with your sample page. First, the script at the bottom of the page uses the v2 API, which changed in v3 (also not necessary in v2, but will throw an error in v3 because MathJax.Hub
is not v3).
Next, you can't load MathJax source files into the browser, at least not without something like System.js to handle the import and export statements in those files. (Version 4 will move to ES modules, so you will be able to load them using , with the correct import mapping, but even then I would only recommend this if you are editing MathJax code , and is not recommended in a production environment.
Instead, you should load one of the webpacked files from the es5
directory. To do this, you don't need a full installation from MathJax-src, instead you can use https://github.com/mathjax/MathJax, which contains everything available from the CDN serving MathJax.
See the MathJax documentation on how to host your own local copy of MathJax for more details.