better-react-mathjax
better-react-mathjax copied to clipboard
Load remote script async to boost performance
By default the script is downloaded at https://cdnjs.cloudflare.com/ajax/libs/mathjax/... without async:
/MathJaxContext/MathJaxContext.js:
function f(t, o) {
n && (window.MathJax = n);
var e = document.createElement("script");
e.type = "text/javascript", e.src = v, e.async = !1, e.addEventListener("load", function () {
var e = window.MathJax;
a && a(e), t(e), r && r()
}), e.addEventListener("error", function (e) { return o(e) }), document.getElementsByTagName("head")[0].appendChild(e)
}
Is it possible to make it async to boost performance?
Yeah sounds like a reasonable thing to ask for, let me test it for a bit and then make a PR :)
Just wanted to let you know that I have not forgotten about this but I need to test it a bit so that this doesn't cause any new circumstances for the ability to hide data until typeset. It shouldn't but I want to try it out first. Will probably release a beta which you can try out too and then add it for the next minor release.
You can try it out now, version 2.0.4-beta1. I will try it out too and make a proper 2.0.4 release once I have confirmed that no hiccups exist :)
Thanks for the suggestion!
seems great so far
Hi again @henrymcl sorry for the long waiting time for such a simple thing. Present on the MathJaxContext in v. 2.1.0 just released is now the boolean asyncLoad which enables you to run the load of the script in an async fashion. Default is still to not run it async. I'll close this for now, let me know if it doesn't work as expected :)
Thanks for contributing with ideas! 🤝