Search code examples
ajaxasynchronousiframesynchronizationclient

If a blocking synchronous call is made in an iframe, will it block the calls made in the main page?


Lets say I have embedded a domain https://imiframe.com as an iframe in a page https://parent.com

If a blocking call is made in the embedded iframe https://imiframe.com , will it block the calls made in the main page https://parent.com ?

Thanks in advance!


Solution

  • Historically this was the case, some modern browsers are moving towards making iframes run in their own thread, but for now at least it is best to assume this is the case until all browsers that your site has to support have been updated.

    If you have a blocking function, you would be best advised to run it in a WebWorker, although these lack access to the DOM and communication with them via PostMessage API also has some overhead. Therefore they are not suited to all use cases.