Fix: sidebar.html charge une seule fois au lieu de deux sur toutes les pages
Reduit de 3 a 2 les fetch au DOMContentLoaded, liberant un slot de connexion HTTP. Corrige le blocage "pending" cause par la limite de 6 connexions simultanees par domaine dans Chrome/Firefox. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -412,23 +412,20 @@
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const elementsToLoad = [
|
||||
{ id: 'topbar', file: 'topbar.html' },
|
||||
{ id: 'sidebar', file: 'sidebar.html' },
|
||||
{ id: 'sidebar_mobile', file: 'sidebar.html' }
|
||||
];
|
||||
// Load topbar
|
||||
fetch('topbar.html')
|
||||
.then(r => r.text())
|
||||
.then(data => { document.getElementById('topbar').innerHTML = data; })
|
||||
.catch(e => console.error('Error loading topbar:', e));
|
||||
|
||||
elementsToLoad.forEach(({ id, file }) => {
|
||||
fetch(file)
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
const element = document.getElementById(id);
|
||||
if (element) {
|
||||
element.innerHTML = data;
|
||||
}
|
||||
})
|
||||
.catch(error => console.error(`Error loading ${file}:`, error));
|
||||
});
|
||||
// Load sidebar once, reuse for desktop + mobile
|
||||
fetch('sidebar.html')
|
||||
.then(r => r.text())
|
||||
.then(data => {
|
||||
document.getElementById('sidebar').innerHTML = data;
|
||||
document.getElementById('sidebar_mobile').innerHTML = data;
|
||||
})
|
||||
.catch(e => console.error('Error loading sidebar:', e));
|
||||
});
|
||||
|
||||
//end document.addEventListener
|
||||
|
||||
Reference in New Issue
Block a user