webstead: mark script as async

Apparently Chromium can't cope with "defer" scripts (which modules are
by default) in XHTML documents.  But "async" scripts work properly,
so now we use one of those and then wait for DOMContentLoaded as
necessary.
This commit is contained in:
Ben Harris 2025-10-04 22:13:04 +01:00
parent 295660b1f9
commit e6c1e44db0

View File

@ -38,7 +38,10 @@
background: currentColor;
}
</style>
<script type="module"><![CDATA[
<!-- Script is async rather than deferred because Chromium can't
handle deferred scripts in XHTML.
https://issues.chromium.org/issues/40518469 -->
<script type="module" async="async"><![CDATA[
import Bedstead from './bedstead.js';
function update_glyph() {
var args = [];
@ -71,10 +74,19 @@
}
});
}
for (var e of document.getElementsByTagName('input')) {
e.onchange = update_glyph;
function init() {
for (var e of document.getElementsByTagName('input')) {
e.onchange = update_glyph;
}
update_glyph();
}
// This script is loaded asynchronously, so make sure the DOM is
// loaded before touching it.
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", init);
} else {
init();
}
update_glyph();
]]>
</script>
</head>