Delay pop up tag with lazy load

791 views Asked by At

I want this popup tag can be loaded after 60 seconds of full page load with Lazy load or jquery. because settimeout and setinterval never worked.

<script type="text/javascript">
    var adfly_id = 17670577;
    var adfly_protocol = 'https';
    var popunder_frequency_delay = 0;
</script>
<script src="https://cdn.ay.gy/js/display.js"></script> 

thank you for your help

1

There are 1 answers

0
Daniel Beck On

setTimeout presumably isn't working because display.js is a wad of self-invoking eval(), so there isn't an obvious thing to wrap the setTimeout around.

But as long as that external code doesn't depend on the window onload event, you should be able to setTimeout the insertion of the script itself:

// jQuery:
window.setTimeout(function() {
  $.getScript('https://cdn.ay.gy/js/display.js');
  // see http://api.jquery.com/jQuery.getScript
}, 60000);

// or without jQuery:
window.setTimeout(function() {
  var s = document.createElement('script');
  s.setAttribute( 'src', 'https://cdn.ay.gy/js/display.js' );
  document.body.appendChild( s );
}