From b6ad08a18231f6965dae27f6a154ec160b256525 Mon Sep 17 00:00:00 2001 From: Folyd Date: Mon, 8 Aug 2022 21:43:42 +0800 Subject: [PATCH] Only load macro railroad wasm file in macro pages --- extension/script/macro-railroad.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extension/script/macro-railroad.js b/extension/script/macro-railroad.js index 246969a..1041f71 100644 --- a/extension/script/macro-railroad.js +++ b/extension/script/macro-railroad.js @@ -5,10 +5,13 @@ document.addEventListener("DOMContentLoaded", async () => { async function load() { if (!isRustDoc()) return; + let macros = document.querySelectorAll('pre.macro'); + if (!macros || macros.length === 0) return; + await wasm_bindgen(chrome.runtime.getURL('wasm/macro-railroad.wasm')); injectCss(); - for (let macro of document.querySelectorAll('pre.macro')) { + for (let macro of macros) { let parentNode = macro.parentNode; if (!parentNode) continue;