mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9829 from tk0miya/9450_load_mathjax_as_defer
Close #9450: mathjax: Load MathJax via "defer" strategy
This commit is contained in:
1
CHANGES
1
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user