开发者

Why are web workers not allowed to modify the dom

开发者 https://www.devze.com 2023-03-28 06:44 出处:网络
I know web workers work as a separate thread than the UI thread but i dont understand why they are not allowed to modify the DOM. I mean that you can allow inter thread communication and keep the DOM

I know web workers work as a separate thread than the UI thread but i dont understand why they are not allowed to modify the DOM. I mean that you can allow inter thread communication and keep the DOM data in a shared space and have the web workers threa开发者_StackOverflowd modify the DOM. Why is this not allowed in browsers?


Because the DOM is not threadsafe, and JavaScript does not expose a thread API.


See also:

  • Is JavaScript multithreaded?
  • Thread Safety in Javascript?
  • Using web workers - About thread safety
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号