Wait for jQuery then Function

<script>
  var counter = 0;
	var waitForjQuery = function () {
	    if ( (typeof jQuery == "function")) {
	        console.log('jquery is defined');
	        const runToolstoPP = setTimeout(runFunction,3000);//need timeout to wait for Data Layer to populate

	    } 
	    else {
	        ++counter;
	        if (counter < 150) { 
	            setTimeout(function () { waitForjQuery(); }, 100);
	        } 
	    } 
	} 

waitForjQuery();

</script>

Posted

in

,

by

Tags: