UNPKG

@phantomstudios/ft-lib

Version:

A collection of Javascript UI & tracking utils for FT sites

31 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadFtCmpScript = loadFtCmpScript; exports.enqueueCmpCallback = enqueueCmpCallback; function loadFtCmpScript() { if (document.getElementById("ft-cmp-loader")) { return Promise.resolve(); } return new Promise(function (resolve, reject) { var script = document.createElement("script"); script.id = "ft-cmp-loader"; script.async = true; script.src = "https://consent-notice.ft.com/cmp.js"; script.referrerPolicy = window.location.hostname.endsWith(".ft.com") ? "" // production hosts : "no-referrer-when-downgrade"; // localhost / preview script.onload = function () { return resolve(); }; script.onerror = function () { return reject(new Error("Sourcepoint CMP script failed to load")); }; document.head.appendChild(script); }); } function enqueueCmpCallback(cb) { if (!window._sp_) window._sp_ = {}; if (!window._sp_.queue) window._sp_.queue = []; window._sp_.queue.push(cb); } //# sourceMappingURL=loadFtCmp.js.map