Does iframe runs on the same thread as the owner?

前端 未结 2 1994
一生所求
一生所求 2021-01-17 15:37

I have a CPU intensive work to do and i don\'t want to degrade the user experience. since web workers (http://ejohn.org/blog/web-workers/) are a new feature and are not supp

2条回答
  •  無奈伤痛
    2021-01-17 15:53

    JavaScript is single-treaded. Separate tabs or windows may run in separate threads or processes depending on the browser, however you cannot communicate between these windows, so there is no way you can explicitly utilize more than one thread or process in JavaScript.

    If it is a question of UI responsiveness, Rushakoff have a good answer. While JavaScript is running, no HTML rendering happens and the UI is not responsive. By using timeouts, control can be released back to the rendering/UI-thread periodically, giving a more responsive feel, even if it still only runs single-threaded.

提交回复
热议问题