Lazy loading MathJax equations for performance

  • Topic: LaTeX 
  • Thread starter Greg Bernhardt
  • Start date
9 replies · 3K views · last reply
Messages
20,012
Reaction score
11,149
To help with performance on threads heavy with equations I got the MathJax dev to create a lazy load extension that only renders the equations if it enters your viewport instead of rendering everything on page load. At the moment it can be a little choppy. The MathJax devs said they'll work on polishing it up for an official release sometime this summer. Let me know your thoughts on the performance improvement and user experience.
 
  • Like
Likes   Reactions: Twigg, DrClaude, Wrichik Basu and 4 others
The post above renders the r, theta, phi expression in portrait mode in Safari on my iPad but only renders the bottom half When in landscape mode.
 
  • Like
Likes   Reactions: Greg Bernhardt
I'm finding (Android Firefox) that sometimes links to posts part way down a LaTeX-heavy page don't go to the top of the post now. For example, this post by sophiatev initially opens at the top, but when the LaTeX renders it jumps to halfway down the post.

I note that she's quoted a lot of LaTeX. Did the stuff she quoted get rendered in the post she quoted it from too or something?
 
Slightly different action here. (Very old Firefox, 43.0.1 on Win XP)

Opens at top
Jumps (part? way) down
Then IMMEDIATELY jumps back to top

A page reload (F5) causes a jump to show the last few lines of the preceeding post for about 1/4 second, then back to top of selected post.

Most curious.

Further trials show suspicion of a local buffering situation. The first anomaly is dependent on the elapsed time between trials.

Arrgh! Now the 1st anomaly has been replaced with the 2nd one.

I give up! Good Luck.
 
Since today, PF Latex formulas are not rendered at all on my PC, in all postings. I tried Firefox (v 89,0, Java script enabled) and Edge (v 91.0.864.41). Both show this issue.
 
  • Like
Likes   Reactions: weirdoguy
I am trying to write a new thread in the Other Physics Topics section, and after writing some LaTeX, when I am clicking on Preview, the equations are not rendered, likely because the MathJax resource is not loaded:

Screenshot of a forum post editor showing raw LaTeX source text for a numerical elliptic PDE problem, with an equation for u^{n+1}_{i,j} written inside double-hash delimiters.


Now, suppose I save the draft, go to some other page, and again come back to the New Thread editor. I find that LaTeX has been rendered even though I have not selected the preview option:

Screenshot of a forum post editor with a rendered equation: u with superscript n+1 and subscript i,j equals the fraction of u_{0,1}^n u_{2,1}^n u_{1,0}^n u_{1,2}^n over 4, minus 0.001.


In this situation, if I click on the Preview button, it becomes a mess:

Screenshot of a forum post editor showing a draft about solving elliptic PDE numerically, with plain text describing Δx=Δy=0.2 and references to Eqn. 1.7 and Eqn. 1.9 for the iteration ui,j+1 formula.
 
Last edited:
  • Informative
Likes   Reactions: Greg Bernhardt