ensure script laod flow is correct

This commit is contained in:
Kuyoshbek 2024-02-15 14:37:07 +05:00
parent eefaed1aab
commit cf9d9e4596
3 changed files with 15 additions and 11 deletions

View file

@ -1,9 +1,14 @@
<script>
import { onMount } from 'svelte';
import { loadBootstrap } from './adScripts/bootstrap';
import { loadScript } from './adScripts/loadScript';
onMount(() => {
window.graphicsAdQueue = window.graphicsAdQueue || [];
loadScript(
'https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js',
loadBootstrap
);
});
</script>
@ -22,15 +27,4 @@
crossorigin=""
/>
<link rel="stylesheet" href="https://a.pub.network/reuters-com/cls.css" />
<script
src="https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js"
on:load="{loadBootstrap}"
></script>
<script
src="https://a.pub.network/reuters-com/pubfig.min.js"
data-cfasync="false"
async
></script>
</svelte:head>

View file

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

View file

@ -0,0 +1,6 @@
export const loadScript = (src: string, onload?: () => void) => {
const script = document.createElement('script');
script.addEventListener('load', onload);
script.src = src;
document.head.append(script);
};