This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instantpage.min.js
2 lines (2 loc) · 3.48 KB
/
instantpage.min.js
1
2
/*! instant.page v5.2.0 - (C) 2019-2024 Alexandre Dieulot - https://instant.page/license */
let t,e,n,o,i,a,r=null,s=65,c=new Set;function u(t){i=t;const e=t.target.closest("a");g(e)&&v(e.href,"high")}function d(t){i=t}function l(t){if(h(t))return;if(!("closest"in t.target))return;const e=t.target.closest("a");g(e)&&(e.addEventListener("mouseout",p,{passive:!0}),a=setTimeout(()=>{v(e.href,"high"),a=null},s))}function f(t){if(h(t))return;const e=t.target.closest("a");g(e)&&v(e.href,"high")}function p(t){t.relatedTarget&&t.target.closest("a")==t.relatedTarget.closest("a")||a&&(clearTimeout(a),a=null)}function m(t){if(h(t))return;const e=t.target.closest("a");if(t.which>1||t.metaKey||t.ctrlKey)return;if(!e)return;e.addEventListener("click",function(t){1337!=t.detail&&t.preventDefault()},{capture:!0,passive:!1,once:!0});const n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,detail:1337});e.dispatchEvent(n)}function h(t){if(!i||!t)return!1;if(t.target!=i.target)return!1;return t.timeStamp-i.timeStamp<2500}function g(t){if(t&&t.href&&(!o||"instant"in t.dataset)){if(t.origin!=location.origin){if(!(n||"instant"in t.dataset)||!r)return}if(["http:","https:"].includes(t.protocol)&&("http:"!=t.protocol||"https:"!=location.protocol)&&(e||!t.search||"instant"in t.dataset)&&!(t.hash&&t.pathname+t.search==location.pathname+location.search||"noInstant"in t.dataset))return!0}}function v(e,n="auto"){c.has(e)||("none"!=t?function(e){const n=document.createElement("script");n.type="speculationrules",n.textContent=JSON.stringify({[t]:[{source:"list",urls:[e]}]}),document.head.appendChild(n)}(e):function(t,e="auto"){const n=document.createElement("link");n.rel="prefetch",n.href=t,n.fetchPriority=e,n.as="document",document.head.appendChild(n)}(e,n),c.add(e))}!function(){const i=document.createElement("link").relList;if(!i.supports("prefetch")||!i.supports("modulepreload"))return;const a="instantVaryAccept"in document.body.dataset||"Shopify"in window,c=navigator.userAgent.indexOf("Chrome/");c>-1&&(r=parseInt(navigator.userAgent.substring(c+"Chrome/".length)));if(a&&r&&r<110)return;if(t="none",HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){const e=document.body.dataset.instantSpecrules;"prerender"==e?t="prerender":"no"!=e&&(t="prefetch")}const p="instantMousedownShortcut"in document.body.dataset;e="instantAllowQueryString"in document.body.dataset,n="instantAllowExternalLinks"in document.body.dataset,o="instantWhitelist"in document.body.dataset;let h=!1,y=!1,w=!1;if("instantIntensity"in document.body.dataset){const t=document.body.dataset.instantIntensity;if("mousedown"!=t||p||(h=!0),"mousedown-only"!=t||p||(h=!0,y=!0),"viewport"==t){const t=document.documentElement.clientWidth*document.documentElement.clientHeight<45e4,e=navigator.connection&&navigator.connection.saveData,n=navigator.connection&&navigator.connection.effectiveType&&navigator.connection.effectiveType.includes("2g"),o=!e&&!n;t&&o&&(w=!0)}"viewport-all"==t&&(w=!0);const e=parseInt(t);isNaN(e)||(s=e)}const E={capture:!0,passive:!0};y?document.addEventListener("touchstart",d,E):document.addEventListener("touchstart",u,E);h||document.addEventListener("mouseover",l,E);h&&document.addEventListener("mousedown",f,E);p&&document.addEventListener("mousedown",m,E);if(w){let t=window.requestIdleCallback;t||(t=(t=>{t()})),t(function(){const t=new IntersectionObserver(e=>{e.forEach(e=>{if(e.isIntersecting){const n=e.target;t.unobserve(n),v(n.href)}})});document.querySelectorAll("a").forEach(e=>{g(e)&&t.observe(e)})},{timeout:1500})}}();