How to load mathjax v3 locally (not using CDN)

155 views
Skip to first unread message

Tom B

unread,
May 23, 2022, 1:12:20 AM5/23/22
to MathJax Users
I have a front end project using webpack, due to performance and some users using my code offline,  I want to be able to load mathjax v3 locally without having to use a CDN or without loading it on a node server (i.e. ship mathjaxv3 alongside my code). I want to be able to import MathjaxV3 locally after installing it using npm. I understand I will need to install it using the full version https://www.npmjs.com/package/mathjax-full . I am not being able to understand how to import it locally and starting it up. I've tried importing the startup file inside es5 folder and loading the mathjax.js file, but I'm not being succesful and I can't seem to find any instructions in the docs http://docs.mathjax.org/en/latest/index.html

I've also tried searching this group for older answers, but nobody seems to have had this issue. 

Is there anyone that managed to solve this? Am I missing something obvious?

Thanks

Tom B

unread,
May 24, 2022, 9:57:28 PM5/24/22
to MathJax Users
Just to clarify I want to to be able to use Mathjax v3 as an import statement on my frontend.

Davide Cervone

unread,
May 30, 2022, 12:11:31 PM5/30/22
to mathja...@googlegroups.com
> I want to be able to import MathjaxV3 locally after installing it using npm. I understand I will need to install it using the full version https://www.npmjs.com/package/mathjax-full.

You should be able to use use the mathjax npm package if you are just using the existing components. It is not clear what your actual use-case is.

> I am not being able to understand how to import it locally and starting it up. I've tried importing the startup file inside es5 folder and loading the mathjax.js file, but I'm not being succesful and I can't seem to find any instructions in the docs http://docs.mathjax.org/en/latest/index.html

You may find the examples in the MathJax node demos repository at

https://github.com/mathjax/MathJax-demos-node

to be helpful. They illustrate several different ways to load MathJax into a node application, and how you do it depends on whether you want to use the prebuilt components (where you use a global MathJax variable to configure how MathJax works), or import the modules directly (see the examples in the "direct" subdirectory).

The demos at

https://github.com/mathjax/MathJax-demos-web

show how to use MathJax in web applications.

Note, however, that many browsers now impose pretty strict rules for the same-origin policy when using file:// URLs, and you may not be able to load MathJax from a different directory from the HTML file, or it may not be able to load the web fonts, for example, so local file access is not always easy to accomplish. You may find using SVG output to be easier to use than CHTML in this setting. You may also find that pre-processing your files (rather than calling MathJax locally) may be the best solution for you. See the examples ending in "-page" in the node demos repository.

Davide
Reply all
Reply to author
Forward
0 new messages