I have intergrated a third party code into my website, and suddenly the setTimeout and setInterval stopped working: Before the third party is loaded, everything works fine. setTimeout and setInterval that were scheduled to run after the third party is loaded, do not dun at all. After removing the 3rd party code snippet they supplied, everything work.
My question is - how can it be? what can the third pary do that can stop my schedules? I renamed any pointers to the returned value of the setTimeout function; I tried to play with the place where I put the snippet and / or the setTimeout code. Nothing work.
It doesn't make any sense. and I don't know how to start debugging it.
Here is a simplified html:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Demo</title>
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico"/>
<!--<link href="css/style.css" rel="stylesheet" type="text/css">-->
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>
<script>
<!-- the alert pops up only when I remove the 3rd party snippet -->
setTimeout(function(){
alert("done");
}, 5000);
</script>
<!-- This is the 3rd party code -->
<script type="text/javascript">
var $P; var prefix = ('https:' == document.location.protocol ? 'https://' : 'http://'); var _P = _P || [];
_P.push(['setId', '123']);
var PPP = document.createElement('script');
PPP.type = 'text/javascript'; PPP.src = prefix + 'thethirdpartyIuse.com/functions.js';
var s = document.getElementsByTagName('script');
var lastScriptTag = s[s.length - 1];
lastScriptTag.parentNode.insertBefore(PPP, lastScriptTag);
</script>
</body>
</html>
Any help & guideness is appriciated!