Only load macro railroad wasm file in macro pages

This commit is contained in:
Folyd 2022-08-08 21:43:42 +08:00
parent f3b73a4316
commit b6ad08a182

View file

@ -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;