Lazy Loading with LaTeX - Performance and UX

  • LaTeX
  • Thread starter Greg Bernhardt
  • Start date
In summary: I think it would be helpful to have a preview button that just renders the equations without any formatting.In summary, the MathJax lazy load extension can be a little choppy, but it has the potential to improve performance on threads heavy with equations. Some browsers ( Firefox and Edge ) show issues when links to posts part way down a LaTeX-heavy page don't go to the top of the post, and clearing the browser cache helps.
  • #1
19,558
10,348
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 Twigg, DrClaude, Wrichik Basu and 4 others
Physics news on Phys.org
  • #2
I noticed in a PM that the it didn’t render at all but when my post was quoted it did.

##(r, \theta, \phi)##
 
  • #3
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 Greg Bernhardt
  • #4
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?
 
  • #5
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.
 
  • #6
I've made a conditional so that if equations aren't found on the page, it won't load the mathjax resource. Let me know if anyone is seeing rendering issues.
 
  • #7
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 weirdoguy
  • #9
Clearing browser cache helped. Thanks!
 
  • Like
Likes Greg Bernhardt
  • #10
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:

1623932856219.png


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:

1623932907781.png


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

1623932967815.png
 
Last edited:
  • Informative
Likes Greg Bernhardt

FAQ: Lazy Loading with LaTeX - Performance and UX

What is lazy loading in LaTeX?

Lazy loading in LaTeX refers to the process of loading images or other external content only when necessary, rather than loading them all at once when the document is opened. This can improve performance and user experience by reducing the initial load time and only loading content that the user actually needs to view.

How does lazy loading affect the performance of a LaTeX document?

Lazy loading can significantly improve the performance of a LaTeX document by reducing the initial load time. This is especially noticeable when the document contains a large number of images or other external content. Lazy loading ensures that only the necessary content is loaded, which can also save memory and processing power.

Are there any downsides to using lazy loading in LaTeX?

One potential downside of lazy loading in LaTeX is that it may slightly delay the loading of certain content. This can be noticeable if the user is scrolling quickly through the document and the content is not already loaded. Additionally, lazy loading may not be compatible with all packages or document classes, so it is important to test and ensure that it does not cause any conflicts.

Can lazy loading improve the user experience of a LaTeX document?

Yes, lazy loading can improve the user experience of a LaTeX document in several ways. By reducing the initial load time, the user can start reading the document sooner. Additionally, lazy loading can also make the document feel more responsive and faster, as content is only loaded when it is needed.

How can I implement lazy loading in my LaTeX document?

There are several packages available for implementing lazy loading in LaTeX, such as lazyload and figlazyload. These packages allow you to specify which content you want to lazy load and provide options for customizing the loading behavior. It is important to carefully follow the instructions and test the document to ensure that lazy loading is working properly.

Similar threads

Replies
3
Views
884
Replies
48
Views
63K
Replies
1
Views
9K
Replies
5
Views
2K
Back
Top