summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-11-10 01:32:43 +0900
committerGitHub <noreply@github.com>2021-11-10 01:32:43 +0900
commit563936b969dfc29ade7d48f1a802d5f6f6348f4c (patch)
tree36869ad1f05c3d36eecc8d9b27282e0bd3f53d97
parent6c6cc8a6f50b18331cb818160d168d7bb9c03e55 (diff)
parent4cd19b8274de7513203738c7a5b6d9d32775cd67 (diff)
downloadsphinx-git-563936b969dfc29ade7d48f1a802d5f6f6348f4c.tar.gz
Merge pull request #9829 from tk0miya/9450_load_mathjax_as_defer
Close #9450: mathjax: Load MathJax via "defer" strategy
-rw-r--r--CHANGES1
-rw-r--r--sphinx/ext/mathjax.py2
-rw-r--r--tests/test_ext_math.py2
3 files changed, 3 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 33d20a45b..0c07f4806 100644
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,7 @@ Incompatible changes
* #9695: The rendering of Javascript domain declarations is implemented
with more docutils nodes to allow better CSS styling.
It may break existing styling.
+* #9450: mathjax: Load MathJax via "defer" strategy
Deprecated
diff --git a/sphinx/ext/mathjax.py b/sphinx/ext/mathjax.py
index 46ca3b332..eb06908d3 100644
--- a/sphinx/ext/mathjax.py
+++ b/sphinx/ext/mathjax.py
@@ -81,7 +81,7 @@ def install_mathjax(app: Sphinx, pagename: str, templatename: str, context: Dict
domain = cast(MathDomain, app.env.get_domain('math'))
if app.registry.html_assets_policy == 'always' or domain.has_equations(pagename):
# Enable mathjax only if equations exists
- options = {'async': 'async'}
+ options = {'defer': 'defer'}
if app.config.mathjax_options:
options.update(app.config.mathjax_options)
app.add_js_file(app.config.mathjax_path, **options) # type: ignore
diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py
index 973fc3699..7c78954b7 100644
--- a/tests/test_ext_math.py
+++ b/tests/test_ext_math.py
@@ -71,7 +71,7 @@ def test_mathjax_options(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'index.html').read_text()
- assert ('<script async="async" integrity="sha384-0123456789" '
+ assert ('<script defer="defer" integrity="sha384-0123456789" '
'src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">'
'</script>' in content)