<script type="text/x-mathjax-config">MathJax.Hub.Register.LoadHook("[MathJax]/jax/output/CommonHTML/fonts/TeX/fontdata.js",function () {var STYLES = MathJax.Hub.config.CommonHTML.styles;MathJax.Hub.config.CommonHTML.styles = {"#MathJax_CHTML_Tooltip": STYLES["#MathJax_CHTML_Tooltip"],".MJXc-processing": STYLES[".MJXc-processing"],".MJXc-processed": STYLES[".MJXc-processed"],".mjx-chartest": STYLES[".mjx-chartest"],".mjx-chartest .mjx-char": STYLES[".mjx-chartest .mjx-char"],".mjx-chartest .mjx-box": STYLES[".mjx-chartest .mjx-box"],".mjx-test": STYLES[".mjx-test"],".mjx-ex-boxtest": STYLES[".mjx-ex-boxtest"]};});</script>
2) For pre-rendered math (using mathjax-node), setting font-display: block; on every generated @font-face makes a local copy of the page load instantly, whereas it was being poorly responsive for several seconds without.
Unfortunately for live math, even with the fonts pre-loaded the MathJax HTML-CSS renderer is too slow to get smooth scrolling while it's busy. CommonHTML is a bit better, but still causes some jitter while scrolling.
EqnChunk: 50
EqnChunkFactor: 1.5
EqnChunkDelay: 100
These values control how “chunky” the display of mathematical expressions will be; that is, how often the equations will be updated as they are processed.
EqnChunk
is the number of equations that will be typeset before they appear on screen. Larger values make for less visual flicker as the equations are drawn, but also mean longer delays before the reader sees anything.
EqChunkFactor
is the factor by which theEqnChunk
will grow after each chunk is displayed.
EqChunkDelay
is the time (in milliseconds) to delay between chunks (to allow the browser to respond to other user interaction).
What I suspect is happening is that when an @font-face directive for a web font is inserted into the page, the browser needs to look through the CSS of all elements to see if any of them need to be updated based on the newly requested font, and if so, the page needs to be played out again (by inserting either blank space or a default font until the web font is loaded).
If I understand correctly, your mathjax-node output is HTML (rather than SVG), so your previews are using the CommonHTML output. For that, you should be including the CSS that you obtained from mathjax-node so that the will format properly. That will include the @font-face CSS needed for CommonHTML output, and since it will be in the page already at the outset, if you use the CommonHTML output for the in-page re-rendering (rather than the HTML-CSS output that your page is configured to use), there is no need for new @font-face CSS to be inserted into the page, and you can avoid the changes that are causing the slow page reflows entirely.
There are several configuration parameters that control how responsive MathJax is while it is rendering the page, and allow you to trade off overall rendering speed for UI responsiveness. For pages with large numbers of equations, you might need to adjust these for better scrolling during rendering, at the cost of taking longer to render all the equations. In your case, since you have pre-rendered equations, that should not be a problem.
Since Javascript is single-threaded, if a javascript program is running, the user interface is blocked. So for something like MathJax that can run for a long time, in order to allow the user to do things like scroll the page or even to let the browser to update the typeset equations on the page, MathJax just voluntarily give up the CPU by pausing for a bit. These parameters control how often MathJax pauses, and for how long.
What I suspect is happening is that when an @font-face directive for a web font is inserted into the page, the browser needs to look through the CSS of all elements to see if any of them need to be updated based on the newly requested font, and if so, the page needs to be played out again (by inserting either blank space or a default font until the web font is loaded).Hm, I would have expected browsers to handle this more efficiently, especially when it has no effect.
There are several configuration parameters that control how responsive MathJax is while it is rendering the page, and allow you to trade off overall rendering speed for UI responsiveness. For pages with large numbers of equations, you might need to adjust these for better scrolling during rendering, at the cost of taking longer to render all the equations. In your case, since you have pre-rendered equations, that should not be a problem.I had already tried playing with these, but unfortunately even with EqnChunk:1, EqnChunkFactor:1 and a large value for EqnChunkDelay, MathJax was still executing in 200ms chunks, which still makes the browser somewhat painful to interact with. My (untested) hypothesis is that typesetting a single equation causes a reflow, and given the large page it takes a while for the browser to perform that reflow (and for some reason, giving a fixed size to a separate container around each equation does not prevent these reflows).