https://electriccombiboilerscompany.com/wp-content/themes/ElectricBoilers/js/lazy-reviews.js?ver=1.0
1(function () { 2 // Helper: execute any <script> tags that came inside the AJAX HTML 3 function runScripts(container) { 4 var scripts = container.querySelectorAll('script'); 5 scripts.forEach(function (oldS) { 6 var s = document.createElement('script'); 7 // Copy attributes (src, async, etc.) 8 for (var i = 0; i < oldS.attributes.length; i++) { 9 var a = oldS.attributes[i]; 10 s.setAttribute(a.name, a.value); 11 } 12 // Inline script content 13 if (oldS.textContent) s.textContent = oldS.textContent; 14 // Replace 15 oldS.parentNode.replaceChild(s, oldS); 16 }); 17 } 18 19 // Ensure Trustindex loader present, then call its init 20 function ensureTrustindexInit(cb) { 21 function callInit() { 22 if (typeof window.tiWidgetInit === 'function') { 23 try { window.tiWidgetInit(); } catch(e){} 24 } 25 if (typeof cb === 'function') cb(); 26 } 27 28 // If loader already present, just init 29 if (document.querySelector('script[src*="trustindex.io/loader"]')) { 30 callInit(); 31 return; 32 } 33 34 // Otherwise add loader 35 var script = document.createElement('script'); 36 script.src = 'https://cdn.trustindex.io/loader.js'; 37 script.onload = callInit; 38 document.body.appendChild(script); 39 } 40 41 // Load reviews via AJAX (only once) 42 var loaded = false; 43 var target = document.getElementById('lazy-reviews'); 44 if (!target) return; 45 46 function loadReviews() { 47 if (loaded) return; 48 loaded = true; 49 50 fetch(REVIEWS_AJAX.url, { 51 method: 'POST', 52 headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, 53 body: 'action=load_google_reviews' 54 }) 55 .then(function (r) { return r.text(); }) 56 .then(function (html) { 57 target.innerHTML = html; 58 59 // Execute <script> tags inside returned HTML 60 runScripts(target); 61 62 // Trustindex init (covers cases where scripts didn't auto-run) 63 ensureTrustindexInit(); 64 65 // Safety: set lazy on any iframes that arrived 66 target.querySelectorAll('iframe').forEach(function (f) { 67 if (!f.hasAttribute('loading')) f.setAttribute('loading', 'lazy'); 68 }); 69 }) 70 .catch(function () { 71 target.innerHTML = '<p>Failed to load reviews.</p>'; 72 }); 73 } 74 75 // Use IntersectionObserver (best), fallback to scroll 76 if ('IntersectionObserver' in window) { 77 var io = new IntersectionObserver(function (entries) { 78 entries.forEach(function (e) { 79 if (e.isIntersecting) { 80 loadReviews(); 81 io.disconnect(); 82 } 83 }); 84 }, { rootMargin: '150px 0px' }); 85 io.observe(target); 86 } else { 87 var onScroll = function () { 88 var rect = target.getBoundingClientRect(); 89 if (rect.top < window.innerHeight + 150) { 90 loadReviews(); 91 window.removeEventListener('scroll', onScroll); 92 } 93 }; 94 window.addEventListener('scroll', onScroll); 95 onScroll(); 96 } 97})();
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.