I'm looking for something similar to jQuery.holdReady() but using only vanilla JS. I have an iframe that is loading some content asynchronously. And a listener outside of the iframe listening to its load event for a cookie to be set. Is there a vanillaJS way to delay that load event until the cookie is set asynchronously.
myiframe.html
<script>
asyncFunction().then(() => {
document.cookie = 'mycookie=value";
// I have to load a third party script after i set the cookie async-ly
appendThirdPartyScriptThatReadsCookie(); // blackbox
manuallyFireLoadEvent(); // if i could use jquery in the frame: jQuery.holdReady()
});
</script>
mainpage.html
<iframe src="myiframe.html">
//I cannot control the way this page listens for the cookie from the iframe.
$('iframe').on('load', () => console.log(document.cookie)); // blackbox