|
@@ -1,6 +1,7 @@
|
|
/*! instant.page v0.0.0 - (C) 2019 Alexandre Dieulot - https://instant.page/license */
|
|
/*! instant.page v0.0.0 - (C) 2019 Alexandre Dieulot - https://instant.page/license */
|
|
|
|
|
|
let urlBeingPreloaded
|
|
let urlBeingPreloaded
|
|
|
|
+let mouseoverTimer
|
|
|
|
|
|
const prefetcher = document.createElement('link')
|
|
const prefetcher = document.createElement('link')
|
|
const isSupported = prefetcher.relList && prefetcher.relList.supports && prefetcher.relList.supports('prefetch')
|
|
const isSupported = prefetcher.relList && prefetcher.relList.supports && prefetcher.relList.supports('prefetch')
|
|
@@ -25,7 +26,7 @@ function mouseoverListener(event) {
|
|
|
|
|
|
linkElement.addEventListener('mouseout', mouseoutListener)
|
|
linkElement.addEventListener('mouseout', mouseoutListener)
|
|
|
|
|
|
- preload(linkElement.href)
|
|
|
|
|
|
+ mouseoverTimer = setTimeout(preload, 65, linkElement.href)
|
|
}
|
|
}
|
|
|
|
|
|
function mouseoutListener(event) {
|
|
function mouseoutListener(event) {
|
|
@@ -65,6 +66,11 @@ function preload(url) {
|
|
}
|
|
}
|
|
|
|
|
|
function stopPreloading() {
|
|
function stopPreloading() {
|
|
|
|
+ if (mouseoverTimer) {
|
|
|
|
+ clearTimeout(mouseoverTimer)
|
|
|
|
+ mouseoverTimer = undefined
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!urlBeingPreloaded) {
|
|
if (!urlBeingPreloaded) {
|
|
return
|
|
return
|
|
}
|
|
}
|