How to detect when mathjax is fully loaded?

霸气de小男生 提交于 2019-12-04 10:13:02

问题


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.


回答1:


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




回答2:


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']);
});


来源:https://stackoverflow.com/questions/3014018/how-to-detect-when-mathjax-is-fully-loaded

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!