Skip to content

Commit 7973ebb

Browse files
committed
fix(mathjax): move MathJax initialization to global scope
Updated MathJax initialization to be accessible globally by assigning it to the window object. This change ensures that MathJax is properly loaded and available for use across the application. Additionally, added 'defer' attribute to script tags for correct loading order.
1 parent 5e13298 commit 7973ebb

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

assets/js/mathjax.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
document.addEventListener('DOMContentLoaded', () => {
2-
MathJax = {
3-
tex: {
4-
inlineMath: [
5-
['$', '$'],
6-
['\\(', '\\)']
7-
],
8-
displayMath: [
9-
['$$', '$$'],
10-
['\\[', '\\]']
11-
],
12-
tags: 'ams'
13-
}
14-
};
15-
});
1+
window.MathJax = {
2+
tex: {
3+
inlineMath: [
4+
['$', '$'],
5+
['\\(', '\\)']
6+
],
7+
displayMath: [
8+
['$$', '$$'],
9+
['\\[', '\\]']
10+
],
11+
tags: 'ams'
12+
}
13+
};

layouts/partials/js-selector.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@
8989
{{ if .Params.math }}
9090
<!-- MathJax -->
9191
{{ $mathjaxConfig := resources.Get "js/mathjax.js" | minify | fingerprint }}
92-
<script src="{{ $mathjaxConfig.RelPermalink }}"></script>
92+
<script src="{{ $mathjaxConfig.RelPermalink }}" defer></script>
9393
<script async src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
94-
<script id="MathJax-script" async src="{{ $data.mathjax.js }}"></script>
94+
<script id="MathJax-script" src="{{ $data.mathjax.js }}" defer></script>
9595
{{ end }}
9696

9797
<!-- Pageviews -->

0 commit comments

Comments
 (0)