react-dfp
Version:
A React implementation of the google [DFP](https://developers.google.com/doubleclick-gpt/reference "GPT Reference") API. This package is inspired in the awesome library [jquery.dfp](https://github.com/coop182/jquery.dfp.js), and aims to provide its same e
36 lines (30 loc) • 1.11 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.loadGPTScript = loadGPTScript;
var GPT_SRC = {
standard: 'securepubads.g.doubleclick.net',
limitedAds: 'pagead2.googlesyndication.com'
};
function doloadGPTScript(resolve, reject, limitedAds) {
window.googletag = window.googletag || {};
window.googletag.cmd = window.googletag.cmd || [];
var scriptTag = document.createElement('script');
scriptTag.src = "".concat(document.location.protocol, "//").concat(limitedAds ? GPT_SRC.limitedAds : GPT_SRC.standard, "/tag/js/gpt.js");
scriptTag.async = true;
scriptTag.type = 'text/javascript';
scriptTag.onerror = function scriptTagOnError(errs) {
reject(errs);
};
scriptTag.onload = function scriptTagOnLoad() {
resolve(window.googletag);
};
document.getElementsByTagName('head')[0].appendChild(scriptTag);
}
function loadGPTScript() {
var limitedAds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
return new Promise(function (resolve, reject) {
doloadGPTScript(resolve, reject, limitedAds);
});
}
;