简体   繁体   中英

Is it possible to leverage cross-domain iframes for non-blocking computation?

According to various documentation sources, iframes from distinct origins have separate event loops so a long-running javascript code in one of them should not affect the event handling in the other, however a simple POC shows that a simple long-running counting loop in the inner iframe blocks the rendering of the entire page even when the inner iframe is set to display:none

EDIT I'm familliar with web workers, this question is about the feasability of doing it in a browser where web workers are not supported (say for the purpose of writing a web-workers polyfill or be able to run existing code that was not designed with web workers in mind)

It seems like an anti-pattern to try hack non-blocking computation into iframes. i expect that https://developer.mozilla.org/en/docs/Web/Guide/Performance/Using_web_workers web workers are meant for such purposes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM