Skip to content

Instantly share code, notes, and snippets.

View davewalker235's full-sized avatar

Dave Walker davewalker235

  • St Thomas, USVI
View GitHub Profile
@davewalker235
davewalker235 / ads.html
Last active February 21, 2022 18:15
Lazyload Google DFP ads with SRA Roadblock
<html>
<head>
<script async="async" src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
// This is a very basic example of Lazyloading DFP ads with an SRA roadblock.
// The example uses ES2016 javascript syntax and relies on
// IntersectionObservers. Normally in production this would be transpiled
// with babel and polyfilled for support. It also relies on DFP maintaining a
// changeCorrelator for all ad requests. Historically this correlator has
// timed out after 30 seconds, which is why this example relies on a js timer