-
Notifications
You must be signed in to change notification settings - Fork 231
Does putting the script tag for MathJax.js just before the closing body tag improve page load time?
You are right that the PAGE begins to display faster, but it will delay the display of the MATHEMATICS on the page, and so it will appear to take longer for the mathematics to be typeset. The reason is that MathJax must load files like the configuration file, extensions, the jax files, and so on. If you put the script that loads MathJax at the TOP of the file, MathJax can begin loading those files right away, whereas if you put the script at the bottom, you delay the loading of those files until the rest of the page is in place. Of course, when placed at the top of the page, the rest of the page will have to wait for MathJax.js to load before it will be displayed at all, and the loading of the extensions and other files will compete with the loading of the rest of the page, and that may also delay the appearance of the page. So the trade-off you are making is between a quick appearance of the page and a slow appearance of the math, versus a slower appearance of the page but with mathematics that appears quicker thereafter. Personally, I prefer the latter, since most people are willing to wait for the page to load (and know that there is delay involved in getting all the pieces) but once the page appears, they expect it to be ready to go, and will find the longer wait for the mathematics to be more annoying. I have not done a formal study of this, but I suspect that it is more an issue of perception rather than actual times that is the most important.
But if you want to put the script that loads MathJax at the bottom, there is no problem (technically speaking) with doing that. MathJax will still work that way.
Davide