-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
153 lines (146 loc) · 7.45 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Deferred Script Loader</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<!-- create the deferScript queue -->
<script>
(function (i,r) {
window.__p1defer = r; i[r] = i[r] || function () {
var args = arguments; (i[r].q = i[r].q || []).push(args);
if (args[0] === 'register' && args[1] && args[1].init) args[1].init();
}
})(window, 'deferScript');
</script>
<!-- load the module -->
<script type="module" src="./src/index.js" async defer></script>
<!-- run -->
<script>
/**
* Initializes the deferScript lib.
* Setting debug to `true` will output console logs
*/
deferScript('init', { debug: true });
deferScript('register', {
name: 'p1events',
src: 'https://cdn.parameter1.com/p1-events/1ed2a30f.js',
esm: true,
on: 'load',
targetTag: 'head',
init: function() { var i = window, r = 'p1events'; i['__p1e'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments); }; }
});
deferScript('register', {
name: 'fortnight',
src: 'https://cdn.parameter1.com/native-x/1.0.0-rc.4.3.js',
on: 'load',
init: function() { var i = window, r = 'fortnight'; i['FortnightObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments); }; }
});
deferScript('register', {
name: 'dataLayer',
src: 'https://www.googletagmanager.com/gtm.js?id=GTM-NDC3FQX',
on: 'load',
init: function() { var w = window, l = 'dataLayer'; w[l] = w[l] || []; },
onScriptLoad: function() {
console.log('DATA LAYER SCRIPT LOADED!!');
}
});
/**
* Registers a new defered script.
*/
deferScript('register', {
/**
* The queue name to use when invoking `deferScript('call')` commands.
*/
name: 'googletag',
/**
* The remote script src to defer.
*/
src: 'https://securepubads.g.doubleclick.net/tag/js/gpt.js',
/**
* Determines when to load the remote script `src`.
* Valid options include: immediate, ready, load, and never.
* This can also be a function that returns the `on` string value.
*/
on: 'ready',
/**
* If set, delays load of the external script until a set time after the `on` event fires.
* When using `initOnly=true`, this delay is still applied when manually calling `load`.
*/
delayMs: 3000,
/**
* Determines whether to execute the script within an animation frame in the browser.
*/
requestFrame: true,
/**
* Queue setup hook.
* The init function must assign a value to the `window` object directly, not declare a local var.
*/
init: function() {
window.googletag = window.googletag || {}; window.googletag.cmd = window.googletag.cmd || [];
googletag.cmd.push(function() { googletag.pubads().setTargeting('uri', '/'); });
googletag.cmd.push(function() { googletag.enableServices(); });
},
/**
* When true, will only call the init function above but will _not_ load the remote script.
* To call the remote script, the `deferScript('load', { name: '' })` call must be executed.
* This is useful when you want to manually control when the script should execute (e.g. on scroll or intersection)
*/
initOnly: false,
/**
* Script attributes to pass.
* By default both async and defer are set.
*/
attrs: { async: 1, defer: 1 },
});
// manually calling the googletag script when using `initOnly=true`.
// deferScript('load', { name: 'googletag' });
deferScript('register', {
name: 'lazysizes',
src: 'http://afarkas.github.io/lazysizes/lazysizes.min.js',
on: 'ready',
});
</script>
</head>
<body>
<div class="container mt-3">
<div class="row">
<div class="col">
<h1>Deferred Script Loader</h1>
<div id="div-gpt-ad-1616266714451-667" class="ad-container__wrapper">
<script>
p1events('init', {
tenant: 'randallreilly',
realm: '5fce561dd28860bc33b823ce',
env: 'production',
debug: true,
uri: 'https://db0y8smio0.execute-api.us-east-2.amazonaws.com/default/p1-website-events-enqueue',
cookieDomain: 'overdriveonline.com',
identityQueryBuilder: function(query) {
var id = query.oly_enc_id;
if (id) return 'omeda.rrpcd.customer*' + id + '~encoded';
}
});
fortnight('init', { domain: 'https://randallreilly.native-x.parameter1.com' });
// since googletag supports its own queue, the googletag call can be done directly or via the `call` method
googletag.cmd.push(function() { googletag.defineSlot('/142181607/ovd/leaderboard', [[970,90],[728,90],[320,100],[300,250],[320,50],[265,149],[1060,596],[736,414],[428,241]], 'div-gpt-ad-1616266714451-667').setTargeting('pos', 'home_page|1').setTargeting('referrer', 'internal').defineSizeMapping(googletag.sizeMapping().addSize([1070,0], [[970,90],[728,90],[265,149],[1060,596]]).addSize([980,0], [[970,90],[728,90],[265,149],[736,414]]).addSize([750,0], [[728,90],[265,149],[736,414]]).addSize([300,0], [[320,100],[300,250],[320,50],[265,149],[428,241]]).build()).setCollapseEmptyDiv(true, true).addService(googletag.pubads()); googletag.display('div-gpt-ad-1616266714451-667'); });
/*
deferScript('call', {
name: 'googletag',
fn: function() {
googletag.cmd.push(function() { googletag.defineSlot('/142181607/ovd/leaderboard', [[970,90],[728,90],[320,100],[300,250],[320,50],[265,149],[1060,596],[736,414],[428,241]], 'div-gpt-ad-1616266714451-667').setTargeting('pos', 'home_page|1').setTargeting('referrer', 'internal').defineSizeMapping(googletag.sizeMapping().addSize([1070,0], [[970,90],[728,90],[265,149],[1060,596]]).addSize([980,0], [[970,90],[728,90],[265,149],[736,414]]).addSize([750,0], [[728,90],[265,149],[736,414]]).addSize([300,0], [[320,100],[300,250],[320,50],[265,149],[428,241]]).build()).setCollapseEmptyDiv(true, true).addService(googletag.pubads()); googletag.display('div-gpt-ad-1616266714451-667'); });
}
});
*/
</script>
</div>
</div>
</div>
<div class="row">
<div class="col">
<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://img.overdriveonline.com/files/base/randallreilly/all/image/2021/03/Haul_of_fame.6054d6d64c241.png?auto=format%2Ccompress&fit=crop&h=400&q=70&w=600" data-srcset="https://img.overdriveonline.com/files/base/randallreilly/all/image/2021/03/Haul_of_fame.6054d6d64c241.png?auto=format%2Ccompress&dpr=2&fit=crop&h=400&q=70&w=600 2x" class="node__image lazyload" alt="Marhoefer, Ken Waugh, 'Fast Freddie' Lieb, and Idella Marie Hansen">
</div>
</div>
</div>
</body>
</html>