Commit f0f7f895 authored by ∞'s avatar 💻

Remove fetch preload poc

parent de82d66c
......@@ -86,33 +86,6 @@ function prefetchCleanup(event) {
event.target.removeEventListener('mouseleave', prefetchCleanup)
}
// link preload on hover poc by @hopsoft
// https://github.com/turbolinks/turbolinks/issues/313#issuecomment-407108379
document.addEventListener('mouseover', event => {
let url = event.target.href
if (!event.target.href) return
clearTimeout(fetchers[url])
if (window.Turbolinks.controller.cache.has(url)) return
if (event.target.dataset.noprefetch) return
event.target.addEventListener('mouseleave', prefetchCleanup)
fetchers[url] = setTimeout(() => {
const iframe = document.createElement('iframe')
iframe.setAttribute('style', 'display:none')
iframe.setAttribute('src', url)
iframe.addEventListener('load', () => {
window.Turbolinks.controller.cache.put(
url,
window.Turbolinks.Snapshot.fromHTMLElement(iframe.contentDocument.documentElement)
)
iframe.parentElement.removeChild(iframe)
})
document.body.appendChild(iframe)
}, 250)
})
document.addEventListener('turbolinks:click', loader.show)
document.addEventListener('turbolinks:render', loader.hide)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment