loading = false, 300)"
        x-init="
        document.addEventListener('DOMContentLoaded', () => {
            setTimeout(() => (loading = false), 300)
        })
        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
            setTimeout(() => {
            window.location.href = link.href
            }, 300)
        }
        document.addEventListener('click', (e) => {
            handleNavigation(e.target)
            if (loading){
                e.preventDefault()
            }
        })
    "
>