vendor: 6,470 bytes, lines 1-232
1/*! instant.page v5.1.0 - (C) 2019-2020 Alexandre Dieulot - https://instant.page/license */ 2( function (){ 3 let mouseoverTimer 4 let lastTouchTimestamp 5 const prefetches = new Set() 6 const prefetchElement = document.createElement( 'link' ) 7 const isSupported = prefetchElement.relList && prefetchElement.relList.supports && prefetchElement.relList.supports( 'prefetch' ) 8 && window.IntersectionObserver && 'isIntersecting' in IntersectionObserverEntry.prototype 9 const allowQueryString = 'instantAllowQueryString' in document.body.dataset 10 const allowExternalLinks = 'instantAllowExternalLinks' in document.body.dataset 11 const useWhitelist = 'instantWhitelist' in document.body.dataset 12 const mousedownShortcut = 'instantMousedownShortcut' in document.body.dataset 13 const DELAY_TO_NOT_BE_CONSIDERED_A_TOUCH_INITIATED_ACTION = 1111 14 15 let delayOnHover = 65 16 let useMousedown = false 17 let useMousedownOnly = false 18 let useViewport = false 19 20 if ('instantIntensity' in document.body.dataset) { 21 const intensity = document.body.dataset.instantIntensity 22 23 if (intensity.substr( 0, 'mousedown'.length ) == 'mousedown') { 24 useMousedown = true 25 if (intensity == 'mousedown-only') { 26 useMousedownOnly = true 27 } 28 } else if (intensity.substr( 0, 'viewport'.length ) == 'viewport') { 29 if (! ( navigator.connection && ( navigator.connection.saveData || ( navigator.connection.effectiveType && navigator.connection.effectiveType.includes( '2g' ) ) ) )) { 30 if (intensity == "viewport") { 31 /* Biggest iPhone resolution (which we want): 414 Ã 896 = 370944 32 * Small 7" tablet resolution (which we donât want): 600 Ã 1024 = 614400 33 * Note that the viewport (which we check here) is smaller than the resolution due to the UIâs chrome */ 34 if (document.documentElement.clientWidth * document.documentElement.clientHeight < 450000) { 35 useViewport = true 36 } 37 } else if (intensity == "viewport-all") { 38 useViewport = true 39 } 40 } 41 } else { 42 const milliseconds = parseInt( intensity ) 43 if (! isNaN( milliseconds )) { 44 delayOnHover = milliseconds 45 } 46 } 47 } 48 49 if (isSupported) { 50 const eventListenersOptions = { 51 capture: true, 52 passive: true, 53 } 54 55 if (! useMousedownOnly) { 56 document.addEventListener( 'touchstart', touchstartListener, eventListenersOptions ) 57 } 58 59 if (! useMousedown) { 60 document.addEventListener( 'mouseover', mouseoverListener, eventListenersOptions ) 61 } else if (! mousedownShortcut) { 62 document.addEventListener( 'mousedown', mousedownListener, eventListenersOptions ) 63 } 64 65 if (mousedownShortcut) { 66 document.addEventListener( 'mousedown', mousedownShortcutListener, eventListenersOptions ) 67 } 68 69 if (useViewport) { 70 let triggeringFunction 71 if (window.requestIdleCallback) { 72 triggeringFunction = ( callback ) => { 73 requestIdleCallback( callback, { 74 timeout: 1500, 75 } ) 76 } 77 } else { 78 triggeringFunction = ( callback ) => { 79 callback() 80 } 81 } 82 83 triggeringFunction( () => { 84 const intersectionObserver = new IntersectionObserver( ( entries ) => { 85 entries.forEach( ( entry ) => { 86 if (entry.isIntersecting) { 87 const linkElement = entry.target 88 intersectionObserver.unobserve( linkElement ) 89 preload( linkElement.href ) 90 } 91 } ) 92 } ) 93 94 document.querySelectorAll( 'a' ).forEach( ( linkElement ) => { 95 if (isPreloadable( linkElement )) { 96 intersectionObserver.observe( linkElement ) 97 } 98 } ) 99 } ) 100 } 101 } 102 103 function touchstartListener( event ) { 104 /* Chrome on Android calls mouseover before touchcancel so `lastTouchTimestamp` 105 * must be assigned on touchstart to be measured on mouseover. */ 106 lastTouchTimestamp = performance.now() 107 108 const linkElement = event.target.closest( 'a' ) 109 110 if (! isPreloadable( linkElement )) { 111 return 112 } 113 114 preload( linkElement.href ) 115 } 116 117 function mouseoverListener( event ) { 118 if (performance.now() - lastTouchTimestamp < DELAY_TO_NOT_BE_CONSIDERED_A_TOUCH_INITIATED_ACTION) { 119 return 120 } 121 122 const linkElement = event.target.closest( 'a' ) 123 124 if (! isPreloadable( linkElement )) { 125 return 126 } 127 128 linkElement.addEventListener( 'mouseout', mouseoutListener, { passive: true } ) 129 130 mouseoverTimer = setTimeout( () => { 131 preload( linkElement.href ) 132 mouseoverTimer = undefined 133 }, delayOnHover ) 134 } 135 136 function mousedownListener( event ) { 137 const linkElement = event.target.closest( 'a' ) 138 139 if (! isPreloadable( linkElement )) { 140 return 141 } 142 143 preload( linkElement.href ) 144 } 145 146 function mouseoutListener( event ) { 147 if (event.relatedTarget && event.target.closest( 'a' ) == event.relatedTarget.closest( 'a' )) { 148 return 149 } 150 151 if (mouseoverTimer) { 152 clearTimeout( mouseoverTimer ) 153 mouseoverTimer = undefined 154 } 155 } 156 157 function mousedownShortcutListener( event ) { 158 if (performance.now() - lastTouchTimestamp < DELAY_TO_NOT_BE_CONSIDERED_A_TOUCH_INITIATED_ACTION) { 159 return 160 } 161 162 const linkElement = event.target.closest( 'a' ) 163 164 if (event.which > 1 || event.metaKey || event.ctrlKey) { 165 return 166 } 167 168 if (! linkElement) { 169 return 170 } 171 172 linkElement.addEventListener( 'click', function( event ) { 173 if (event.detail == 1337) { 174 return 175 } 176 177 event.preventDefault() 178 }, { capture: true, passive: false, once: true } ) 179 180 const customEvent = new MouseEvent( 'click', { view: window, bubbles: true, cancelable: false, detail: 1337 } ) 181 linkElement.dispatchEvent( customEvent ) 182 } 183 184 function isPreloadable( linkElement ) { 185 if (! linkElement || ! linkElement.href) { 186 return 187 } 188 189 if (useWhitelist && ! ( 'instant' in linkElement.dataset )) { 190 return 191 } 192 193 if (! allowExternalLinks && linkElement.origin != location.origin && ! ( 'instant' in linkElement.dataset )) { 194 return 195 } 196 197 if (! [ 'http:', 'https:' ].includes( linkElement.protocol )) { 198 return 199 } 200 201 if (linkElement.protocol == 'http:' && location.protocol == 'https:') { 202 return 203 } 204 205 if (! allowQueryString && linkElement.search && ! ( 'instant' in linkElement.dataset )) { 206 return 207 } 208 209 if (linkElement.hash && linkElement.pathname + linkElement.search == location.pathname + location.search) { 210 return 211 } 212 213 if ('noInstant' in linkElement.dataset) { 214 return 215 } 216 217 return true 218 } 219 220 function preload( url ) { 221 if (prefetches.has( url )) { 222 return 223 } 224 225 const prefetcher = document.createElement( 'link' ) 226 prefetcher.rel = 'prefetch' 227 prefetcher.href = url 228 document.head.appendChild( prefetcher ) 229 230 prefetches.add( url ) 231 } 232})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.