MathJax is not applied on initial load. It works after refreshing webpage

[ad_1]

Plugin Author
pkra

(@pkra)

Hard to say without a live page. My first guess would be that there’s SPA-like routing happening, i.e., clicking a link fetches some data and replaces the body HTML on the fly.

In that case, MathJax needs to be triggered to render the fresh content, see https://docs.mathjax.org/en/latest/advanced/typeset.html

Thread Starter
Keith

(@keithkhl)

@pkra Thank you for the quick feedback.

This is an example live page that you can take a look.

Regarding MathJax.typeset(), by this doc, Typesetting and Converting Mathematics — MathJax 3.2 documentation, it seems like the process should be automatic, but somehow on my website, another process blocks the MathJax JS to be called (or loaded) properly.

Plugin Author
pkra

(@pkra)

A quick look seems to confirm SPA-style routing.

this doc, Typesetting and Converting Mathematics — MathJax 3.2 documentation, it seems like the process should be automatic

That page specifically says:

it will do this automatically when it is first loaded

(emphasis mine). When the site adds/replaces content dynamically, MathJax has already completed its automatic-on-load rendering.

First, I’d try to figure out how the site is doing its client-side routing. Ideally, that will tell you how to hook into the routing. Then a script can leverage that hook to trigger mathjax – the link I had posted earlier will help with the MathJax part.

Marking this as resolved since it is not an issue with this plugin but the way MathJax and the site’s design interact.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer