fast-reflexes/better-react-mathjax

Load remote script async to boost performance

Opened this issue · 4 comments

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