When the page loads, use the DOMContentLoaded event to run the first fetch. code example
Example: listerner content loaded js
window.addEventListener('DOMContentLoaded', (event) => {
console.log('DOM fully loaded and parsed');
});
window.addEventListener('DOMContentLoaded', (event) => {
console.log('DOM fully loaded and parsed');
});