// How to use // async function includeHTML() { const elements = document.querySelectorAll("[w3-include-html]"); if (elements.length === 0) { return; // Plus rien à charger } const promises = Array.from(elements).map(async (elmnt) => { const file = elmnt.getAttribute("w3-include-html"); if (!file) return; try { const response = await fetch(file); if (response.ok) { const html = await response.text(); elmnt.innerHTML = html; } else { elmnt.innerHTML = "Page not found."; } } catch (error) { console.error(`Error loading ${file}:`, error); elmnt.innerHTML = "Error loading content."; } elmnt.removeAttribute("w3-include-html"); }); // Attendre que tous les fichiers soient chargés await Promise.all(promises); await includeHTML(); }