1window.addEventListener('load', () => { 2 const masterAssetLoader = async () => { 3 const lazyAssets = document.querySelectorAll( 4 'link[type="text/lazy-style"], script[type="text/lazy-script"]' 5 ); 6 7 const loadStylesheet = (el) => 8 new Promise((resolve, reject) => { 9 const link = document.createElement('link'); 10 link.rel = 'stylesheet'; 11 link.href = el.getAttribute('data-src'); 12 link.onload = () => { 13 el.remove(); 14 resolve(); 15 }; 16 link.onerror = () => 17 reject(new Error(`Failed to load CSS: ${el.getAttribute('data-src')}`)); 18 document.head.appendChild(link); 19 }); 20 21 const loadExternalScript = (el) => 22 new Promise((resolve, reject) => { 23 const script = document.createElement('script'); 24 script.src = el.getAttribute('data-src'); 25 script.async = false; 26 script.onload = () => { 27 el.remove(); 28 resolve(); 29 }; 30 script.onerror = () => 31 reject(new Error(`Failed to load JS: ${el.getAttribute('data-src')}`)); 32 document.body.appendChild(script); 33 }); 34 35 const runInlineScript = (el) => { 36 const text = el.textContent; 37 if (text && text.trim()) { 38 const inline = document.createElement('script'); 39 inline.text = text; 40 document.body.appendChild(inline); 41 } 42 el.remove(); 43 }; 44 45 for (const el of lazyAssets) { 46 try { 47 if (el.matches('link[type="text/lazy-style"]')) { 48 await loadStylesheet(el); 49 continue; 50 } 51 52 const src = el.getAttribute('data-src'); 53 if (!src) { 54 runInlineScript(el); 55 } else { 56 await loadExternalScript(el); 57 } 58 } catch (e) { 59 console.error(e); 60 } 61 } 62 63 window.dispatchEvent(new CustomEvent('lazyassets:ready')); 64 }; 65 66 if ('requestIdleCallback' in window) { 67 requestIdleCallback(masterAssetLoader, { timeout: 2000 }); 68 } else { 69 setTimeout(masterAssetLoader, 50); 70 } 71});
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.