MathJax fails to render in hexo icarus

MathJax fails to render in hexo icarus

In the Hexo Icarus theme, when navigating between pages, MathJax doesn’t render immediately; it only renders after refreshing the page.

This issue occurs because MathJax scripts are not being re-initialized on page transitions, which are typically handled by pjax in themes with smooth page transitions.

To fix this, you can force MathJax to re-render on every end of the pjax event by using the following approach:

1
2
3
4
5
6
// listen pjax:complete event in pjax.js
document.addEventListener('pjax:complete', function () {
// MathJax is global, can be used directly
MathJax.typesetPromise();
});

Author

Breynald

Posted on

2024-09-27

Updated on

2025-05-28

Licensed under

Comments