loading = false, 300)"
x-init="
document.addEventListener('DOMContentLoaded', () => {
setTimeout(() => (loading = false), 200)
})
window.addEventListener('beforeunload', () => {
loading = true
setTimeout(() => {
loading = false
}, 3000)
})
const handleNavigation = (element) => {
const link = element.closest('a')
if (
! link ||
! link.href ||
link.hasAttribute('target') ||
link.href.startsWith('tel:') ||
link.href.startsWith('mailto:') ||
link.hasAttribute('download') ||
link.classList.contains('no-loader')
) {
return
}
const location = window.location
const currentPath = location.pathname + location.search + location.hash
const url = new URL(link.href)
const path = url.pathname + url.search + url.hash
if (currentPath === path) {
return
}
loading = true
}
document.addEventListener('click', (e) => {
handleNavigation(e.target)
})
"
>