diff --git a/src/core/algorithms.js b/src/core/algorithms.js index a693248ca9..8e2d94a87a 100644 --- a/src/core/algorithms.js +++ b/src/core/algorithms.js @@ -7,8 +7,6 @@ import { fetchAsset } from "./text-loader.js"; export const name = "core/algorithms"; -const cssPromise = loadStyle(); - async function loadStyle() { try { return (await import("text!../../assets/algorithms.css")).default; @@ -24,7 +22,7 @@ export async function run() { .forEach(li => li.classList.add("assert")); if (document.querySelector(".assert")) { const style = document.createElement("style"); - style.textContent = await cssPromise; + style.textContent = await loadStyle(); document.head.appendChild(style); } } diff --git a/src/core/biblio.js b/src/core/biblio.js index 77217f65ce..c13d2dd02d 100644 --- a/src/core/biblio.js +++ b/src/core/biblio.js @@ -18,13 +18,16 @@ export const name = "core/biblio"; const bibrefsURL = new URL("https://specref.herokuapp.com/bibrefs?refs="); -// Opportunistically dns-prefetch to bibref server, as we don't know yet -// if we will actually need to download references yet. -const link = createResourceHint({ - hint: "dns-prefetch", - href: bibrefsURL.origin, -}); -document.head.appendChild(link); +export async function prepare() { + // Opportunistically dns-prefetch to bibref server, as we don't know yet + // if we will actually need to download references yet. + const link = createResourceHint({ + hint: "dns-prefetch", + href: bibrefsURL.origin, + }); + document.head.appendChild(link); +} + let doneResolver; /** @type {Promise} */ diff --git a/src/core/data-type.js b/src/core/data-type.js index 25742a0827..aaa184b64f 100644 --- a/src/core/data-type.js +++ b/src/core/data-type.js @@ -9,8 +9,6 @@ import { fetchAsset } from "./text-loader.js"; export const name = "core/data-type"; -const tooltipStylePromise = loadStyle(); - async function loadStyle() { try { return (await import("text!../../assets/datatype.css")).default; @@ -25,7 +23,7 @@ export async function run(conf) { } const style = document.createElement("style"); - style.textContent = await tooltipStylePromise; + style.textContent = await loadStyle(); document.head.appendChild(style); let section = null; diff --git a/src/core/examples.js b/src/core/examples.js index 7fa1a4f489..2908c0b061 100644 --- a/src/core/examples.js +++ b/src/core/examples.js @@ -39,8 +39,6 @@ const localizationStrings = { const l10n = getIntlData(localizationStrings); -const cssPromise = loadStyle(); - async function loadStyle() { try { return (await import("text!../../assets/examples.css")).default; @@ -80,7 +78,7 @@ export async function run() { ); if (!examples.length) return; - const css = await cssPromise; + const css = await loadStyle(); document.head.insertBefore( html`