MathJax.startup.promise timing issue
Created by: holgerengels
Hi .. I have a problem loading mathjax in a webapp.
I am using the following code to load mathjax in my index.html
:
<script>
function loadScript(url) {
return new Promise(function(resolve, reject) {
const script = document.createElement('script');
script.type = "text/javascript";
script.async = true;
script.src = url;
script.onload = resolve;
script.onerror = reject;
document.head.appendChild(script);
})
}
window.MathJax = { loader: {load: ['input/asciimath', 'output/svg']} };
window.MathJaxLoader = loadScript("https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js")
.then(() => console.log("loaded"))
.then(() => window.MathJax.startup.promise)
.then(() => console.log("initialized"))
.then(() => console.log(window.MathJax.asciimath2svg))
;
</script>
In chrome's console, I see the output ..
loaded
initialized
undefined
Shouldn't window.MathJax.asciimath2svg be defined when the startup.promise
has resolved?