Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect when mathjax is fully loaded?

Tags:

mathjax

Is there anyway to identify when the mathjax is fully loaded to process mathematics. I need to hide my mathematics equations before mathjax is fully loaded and show 'loading' message in mean time.

like image 958
robert Avatar asked Jun 10 '10 11:06

robert


People also ask

Is MathJax slow?

I found that MathJax is extremely slow. Is there a better, lighter and faster Javascript library that can render mathematical notation equally well? It may be your browser that is slow.

How do you copy MathJax?

Whenever I want to copy/paste a MathJax snippet from a question or an answer on our site I follow the procedure of 1) click the "Edit"-button under the post, 2) copy the formula from the source to the clipboard, 3) close the edit window without saving, 4) go and paste the snippet wherever it is needed.


2 Answers

For those who might be looking for the answer, this is the response i got from Mathjax developer

The way to synchronize with MathJax's startup actions it to register a StartupHook that will fire when the startup is complete. For example, you can use

MathJax.Hub.Register.StartupHook("End",function () { ... your startup code here ... });

at the end of the tag that configures MathJax, or in a separate tag just after loading MathJax if you are using the default MathJax configuration file in MathJax/config/MathJax.js. That should let you hook into MathJax's initialization sequence so you can do your own setup at the right time.

Thanks David

like image 54
robert Avatar answered Sep 30 '22 19:09

robert


If you have Jquery loaded you can use getScript()

var mjaxURL  = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML,Safe.js';
// load mathjax script
$.getScript(mjaxURL, function() {
    // mathjax successfully loaded, let it render
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, 'c'+parentid+'_list']);
});
like image 26
Avatar Avatar answered Sep 30 '22 18:09

Avatar