I want to get third party function execution time in own script. Because i want to break execution if this function take more then 2 sec.Please help if any one have any idea or suggestion to achieve the same. I am using this code :--
<script>//Tag added by editor
var myextScript = document.createElement('script');
myextScript.type = 'text/javascript';
myextScript.src = '//securepubads.g.doubleclick.net/tag/js/gpt.js'; document.getElementsByTagName('head')[0].appendChild(myextScript);
window.googletag = window.googletag || {cmd: []};
window.setTimeout(function () {
if ( 'pubads' in window) { //check third party function.
googletag.cmd.push(function() {
googletag.defineSlot('ads-name-here',
[[970, 90], 'fluid', [728, 90],[970, 250]], 'div-gpt-ad-1569239177281-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
googletag.cmd.push(function() { googletag.display('slot-id'); });
$('#responce').html('`enter code here`<h3>Adds Loads Successfully !');
});
} else {
$('#responce').html('<h3>Adds not Loaded. Because js file not loaded with in time !');
}
}, 2000);
</script>
Adds Loads Successfully !'); } else { $('#responce').html('
– Thath Singh Sep 27 '19 at 08:20Adds not Loaded. Because js file not loaded with in time !'); } }, 2000);