(async function () { async function loadInto(selector, url) { const mount = document.querySelector(selector); if (!mount) return; try { const res = await fetch(url); if (!res.ok) throw new Error("HTTP " + res.status); const html = await res.text(); mount.innerHTML = html; } catch (e) { // Fail open: if includes fail, keep page usable. // Intentionally no console noise. } } // Pages opt-in by including:
// and/or await Promise.all([ loadInto('[data-include="header"]', "/partials/header.html"), loadInto('[data-include="footer"]', "/partials/footer.html"), ]); // If a page uses includes, it likely removed the built-in header/footer. // Re-run site.js behaviors after injection. if (document.querySelector('[data-include="header"], [data-include="footer"]')) { const s = document.createElement("script"); s.src = "/assets/js/site.js"; s.defer = true; document.head.appendChild(s); } })();