document.addEventListener("DOMContentLoaded", () => { function replaceContent(elm, file) { if (!elm) return; if (!file) return; if (file=="") return; fetch(file).then((resp) => { return resp.text(); }).then((text) => { elm.textContent = text; }); } for (let elm of document.querySelectorAll(".replace")) { replaceContent(elm, elm.getAttribute("file")); } });