From 274b6cdcec8746126103399c4674dd442c2757fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Gastinel?= <264859180+gastinelt@users.noreply.github.com> Date: Mon, 12 Oct 2026 16:16:17 +0200 Subject: [PATCH] Ecran de chargement : retire des que polices + image du haut sont pretes, 1150 ms max (au lieu de 1800 ms fixes) Co-Authored-By: Claude Opus 5.5 --- index.html | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 8e3397e..fcb314e 100644 --- a/index.html +++ b/index.html @@ -3799,11 +3799,24 @@ function boot(){ var loader=document.getElementById('loader-wrapper'); scrollLock.lock(); go(location.hash.replace('#','')||DEFAULT); - setTimeout(function(){ + // Écran de chargement : retiré dès que le minimum est prêt (polices du haut + // de page + image préchargée du carrousel), au plus tard après 1150 ms. + var hidden=false; + function hideLoader(){ + if(hidden) return; hidden=true; loader.classList.add('fade-out'); document.body.classList.remove('no-scroll'); scrollLock.unlock(); - },1800); + } + setTimeout(hideLoader,1150); + if(window.Promise){ + var waits=[]; + // fonts.load() force le téléchargement (fonts.ready peut se résoudre trop tôt). + if(document.fonts&&document.fonts.load){ waits.push(document.fonts.load('400 1em Inter'),document.fonts.load('700 1em Comfortaa')); } + var heroLink=document.querySelector('link[rel="preload"][as="image"]'); + if(heroLink){ var hero=new Image(); hero.src=heroLink.href; if(hero.decode) waits.push(hero.decode()); } + Promise.all(waits).then(hideLoader,hideLoader); + } } if(document.readyState!=='loading') boot(); else document.addEventListener('DOMContentLoaded',boot);