1(function () { 2 // Only on Explore template 3 function onExplore() { 4 return document.body.classList.contains('page-template-template-explore-bol'); 5 } 6 7 // Lightweight prefetch helper 8 function prefetch(url) { 9 if (!url || url.indexOf('#') !== -1) return; 10 try { 11 // Avoid duplicate <link> for same URL 12 if (document.querySelector('link[rel="prefetch"][href="' + url + '"]')) return; 13 const l = document.createElement('link'); 14 l.rel = 'prefetch'; 15 l.href = url; 16 l.as = 'document'; 17 document.head.appendChild(l); 18 } catch (e) {} 19 } 20 21 // Attach listeners to current cards 22 function wire(scope) { 23 const cards = (scope || document).querySelectorAll('.wpgb-card'); 24 cards.forEach(card => { 25 if (card.dataset.bolPrefetch === '1') return; 26 const a = card.querySelector('.bol-card-title a, h2 a, h3 a, a.card-cta, .bol-card-overlay'); 27 if (!a || !a.href) return; 28 29 const url = a.href; 30 const hover = () => prefetch(url); 31 const touch = () => prefetch(url); 32 33 card.addEventListener('mouseenter', hover, { passive: true }); 34 card.addEventListener('focusin', hover, { passive: true }); // keyboard focus 35 card.addEventListener('touchstart', touch, { passive: true }); // mobile tap 36 37 card.dataset.bolPrefetch = '1'; 38 }); 39 } 40 41 document.addEventListener('DOMContentLoaded', function () { 42 if (!onExplore()) return; 43 wire(); 44 45 // Re-wire after WPGB updates the grid 46 document.addEventListener('wpgb:updated', function (e) { 47 wire(e.target || document); 48 }, { passive: true }); 49 50 // Fallback: observe DOM changes 51 const grid = document.querySelector('.wpgb-grid'); 52 if (grid) { 53 const mo = new MutationObserver(() => wire(grid)); 54 mo.observe(grid, { childList: true, subtree: true }); 55 } 56 }); 57})();
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.