document.addEventListener('pjax:error', (e) => { if (e.request.status === 404) { pjax.loadUrl('/404.html') } })