Reputation: 9977
I have the following standard code supplied by Google DFP. Unfortunately it is being listed as a parser-blocking, cross-origin script because it is implemented using document.write
<script>
(function() {
var useSSL = 'https:' == document.location.protocol;
var src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
})();
</script>
I find this really odd because this is a standard DFP script from Google themselves. Is there an updated version that I should be using?
Upvotes: 4
Views: 705
Reputation: 154
You can use this:
(function () {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' === document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
}());
Upvotes: 1