1function lazyLoadDiv() { 2 if ('IntersectionObserver' in window) { 3 var lazyLoadElements = document.querySelectorAll('[cnd-lazy-load]'); 4 var observer = new IntersectionObserver(function (entries, observer) { 5 entries.forEach(function (entry) { 6 if (entry.isIntersecting) { 7 var lazyLoadElementIndex = entry.target.getAttribute('cnd-lazy-load'); 8 var iframeEmbed = decodeHtml(window['cndLazyLoadCode' + lazyLoadElementIndex]); 9 var scriptFilePattern = /\(document,\s?'script',\s?'(.*?)'\)/gmi; 10 var scriptFileMatches = []; 11 var match; 12 while ((match = scriptFilePattern.exec(iframeEmbed)) !== null) { 13 scriptFileMatches.push(match); 14 } 15 var scriptFileContent = []; 16 scriptFileMatches.forEach(function (match) { 17 scriptFileContent.push(match[1]); 18 iframeEmbed = iframeEmbed.replace(match[0], ''); 19 }); 20 var scriptPattern = /<\s*script[^>]*>((.|\n|\r)*?)<\s*\/\s*script>/gmi; 21 var matches = []; 22 while ((match = scriptPattern.exec(iframeEmbed)) !== null) { 23 matches.push(match); 24 } 25 var scriptContent = ''; 26 matches.forEach(function (match) { 27 // append script content to be output later 28 scriptContent += match[1]; 29 // remove the script tag from the iframe embed code 30 iframeEmbed = iframeEmbed.replace(match[0], ''); 31 }); 32 entry.target.innerHTML = iframeEmbed; 33 observer.unobserve(entry.target); 34 var newScript = document.createElement('script'); 35 newScript.textContent = scriptContent; 36 document.body.append(newScript); 37 scriptFileContent.forEach(function (scriptFile) { 38 var newScript = document.createElement('script'); 39 newScript.src = scriptFile; 40 document.body.append(newScript); 41 }); 42 } 43 }); 44 }); 45 46 // Start observing the target element 47 lazyLoadElements.forEach(function (lazyLoadElement) { 48 observer.observe(lazyLoadElement); 49 }); 50 } else { 51 // Fallback for browsers that do not support Intersection Observer 52 // You can load the content immediately or use another method 53 console.log('Intersection Observer not supported'); 54 } 55} 56function decodeHtml(html) { 57 var txt = new DOMParser().parseFromString(html, 'text/html'); 58 return txt.documentElement.textContent; 59} 60document.addEventListener('DOMContentLoaded', function () { 61 lazyLoadDiv(); 62}); 63//# sourceMappingURL=lazy-load.js.map
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.