1/** 2 * A few lines of javascript to help the Google Ad Manager for WordPress plugin 3 * Extends jquery.dfw.min.js with some event listeners specific to us: 4 * 5 * - lazyload 6 */ 7(function() { 8 var $ = jQuery; 9 10 // On window scroll check if there are any new ads to load. 11 var lazyLoad = function() { 12 // all the lazy load ads on the page. 13 var lazyLoaders = $( '.dfw-lazy-load:not(.dfw-loaded)' ), 14 // jQuery object to hold ads that actually need loading. 15 toLoad = $( [] ), 16 // window scrolltop. 17 st = $( document ).scrollTop(), 18 // window height. 19 wh = $( window ).height(); 20 21 // determind with lazyLoaders needs toLoad. 22 lazyLoaders.each(function () { 23 var top = $( this ).offset().top; 24 25 // how much futher down the page to load 26 // the ad (so it's at least loading before it's on screen). 27 var buffer = 200; 28 if (top < st + wh + buffer) { 29 toLoad = toLoad.add( $( this ) ); 30 } 31 }); 32 33 // if we have some ads, then load 'em! 34 if (toLoad.length > 0) { 35 dfp_options = Object.assign( dfw, { 36 "collapseEmptyDivs": false, 37 "sizeMapping": dfw.mappings, 38 "setTargeting": dfw.targeting 39 }); 40 window.dfp_options = dfp_options; 41 $( toLoad ).dfp( dfp_options ).addClass( 'dfw-loaded' ); 42 } 43 }; 44 45 $( document ).ready(function(){ 46 // Watch for scroll events, and determine whether any ads 47 // need lazy loading. Wait a few seconds for images and text to render 48 // and units to reach their "true" depth on the page. 49 $( window ).on( 'scroll', lazyLoad ); 50 51 // Run lazyLoad once on DOM ready to load any ads in view 52 lazyLoad(); 53 }); 54})();
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.