Defer loading of KaTeX JS and Bergamot support code

This commit is contained in:
Danila Fedorin 2023-12-30 19:54:42 -08:00
parent c09fff455f
commit fdcd4ddd60
3 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,7 @@
<script src="{{ .Site.Params.bergamotJsUrl }}"></script>
<script defer src="{{ .Site.Params.bergamotJsUrl }}"></script>
{{ $style := resources.Get "scss/bergamot.scss" | resources.ToCSS | resources.Minify }}
<link rel="stylesheet" href="{{ $style.Permalink }}">
<script>
<script defer>
const renderRules =
`
PrecApp @ prec(app(?l, ?r), 100, left) <-;

View File

@ -1,4 +1,6 @@
<div id="{{ .Get "id" }}"></div>
<script>
window.Bergamot.run(null, '{{ .Get "id" }}', '{{ .Get "prompt" }}', '{{ .Inner }}', renderRules, '{{ .Get "query" }}');
window.addEventListener('load', function() {
window.Bergamot.run(null, '{{ .Get "id" }}', '{{ .Get "prompt" }}', '{{ .Inner }}', renderRules, '{{ .Get "query" }}');
});
</script>

View File

@ -1,4 +1,4 @@
<script src="{{ .Site.Params.katexJsUrl }}" crossorigin="anonymous"></script>
<script defer src="{{ .Site.Params.katexJsUrl }}" crossorigin="anonymous"></script>
<script defer>
class KatexExpressionShim extends HTMLElement {
static observedAttributes = ["expression", "katex-options"];