Merge pull request #147 from reuters-graphics/ad-flow-fix

Change script load flow to make it identical to initial implementation
This commit is contained in:
Jon McClure 2024-04-08 13:05:03 +01:00 committed by GitHub
commit 7846ddd209
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 6 deletions

View file

@ -8,8 +8,10 @@
window.graphicsAdQueue = window.graphicsAdQueue || [];
loadScript(
'https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js',
loadBootstrap
{ onload: loadBootstrap, async: false }
);
// Load Freestar script
loadScript('https://a.pub.network/reuters-com/pubfig.min.js');
});
</script>

View file

@ -1,6 +1,5 @@
import getParameterByName from './getParameterByName';
import Ias from './ias';
import { loadScript } from './loadScript';
const ONETRUST_LOGS = 'ot_logs';
const ONETRUST_GEOLOCATION_MOCK = 'ot_geolocation_mock';
@ -42,9 +41,6 @@ export const loadBootstrap = () => {
);
(<any>window).bootstrap.getResults((result) => {
// Load Freestar script
loadScript('https://a.pub.network/reuters-com/pubfig.min.js');
// Set GAM
window.googletag = (<any>window).googletag || { cmd: [] };
window.googletag.cmd.push(() => {

View file

@ -1,6 +1,14 @@
export const loadScript = (src: string, onload?: () => void) => {
interface attributesInterface {
onload?: () => void,
async?: boolean
}
export const loadScript = (src: string, attributes?: attributesInterface) => {
const { onload, async = true } = attributes || {};
const script = document.createElement('script');
script.addEventListener('load', onload);
script.async = async;
script.src = src;
document.head.append(script);
};