Is JavaScript multithreaded?

前端 未结 9 1997
误落风尘
误落风尘 2020-11-27 04:23

Here\'s my issue - I need to dynamically download several scripts using jQuery.getScript() and execute certain JavaScript code after all the scripts were loaded, so my plan

9条回答
  •  旧巷少年郎
    2020-11-27 05:01

    The JavaScript (ECMAScript) specification does not define any threading or synchronization mechanisms.

    Moreover, the JavaScript engines in our browsers are deliberately single-threaded, in part because allowing more than one UI thread to operate concurrently would open an enormous can of worms. So your assumption and implementation are correct.

    As a sidenote, another commenter alluded to the fact that any JavaScriptengine vendor could add threading and synchronization features, or a vendor could enable users to implement those features themselves, as described in this article: Multi-threaded JavaScript?

提交回复
热议问题