1/** 2 * Scroll to Top on Hard Reload Only 3 * Avoids window "load" scroll (CLS/LCP) and soft navigations. 4 */ 5 6(function () { 7 'use strict'; 8 9 function isHardReload() { 10 try { 11 var navEntries = performance.getEntriesByType && performance.getEntriesByType('navigation'); 12 if (navEntries && navEntries.length && navEntries[0].type) { 13 return navEntries[0].type === 'reload'; 14 } 15 if (performance.navigation) { 16 return performance.navigation.type === 1; 17 } 18 } catch (e) {} 19 return false; 20 } 21 22 if (!isHardReload()) { 23 return; 24 } 25 26 if ('scrollRestoration' in history) { 27 history.scrollRestoration = 'manual'; 28 } 29 30 function scrollToTop() { 31 try { 32 window.scrollTo({ top: 0, left: 0, behavior: 'instant' }); 33 } catch (e) { 34 window.scrollTo(0, 0); 35 } 36 if (document.documentElement) { 37 document.documentElement.scrollTop = 0; 38 } 39 if (document.body) { 40 document.body.scrollTop = 0; 41 } 42 } 43 44 // Run as early as possible; do NOT re-scroll on window "load" 45 // (that fights image/layout settle and hurts mobile CLS/LCP). 46 scrollToTop(); 47})();
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.