最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is DOM manipulation asynchronous (when using the API provided by the browsers like getElementById or appendChild)?

programmeradmin6浏览0评论

This bugs me. I just watched Philip Roberts's video about the event loop and got an understanding of how the API calls will eventually put callbacks in the callback queue. But he only mentioned the XMLHtppRequest and the time out functions. What about DOM API (document.getElementById, document.appendChild)? Does they make the same effect?

This bugs me. I just watched Philip Roberts's video about the event loop and got an understanding of how the API calls will eventually put callbacks in the callback queue. But he only mentioned the XMLHtppRequest and the time out functions. What about DOM API (document.getElementById, document.appendChild)? Does they make the same effect?

Share Improve this question asked May 6, 2018 at 13:40 Best_NameBest_Name 1593 silver badges13 bronze badges 1
  • Is DOM manipulation asynchronous (when using the API provided by the browsers like getElementById or appendChild)? I don't think so – Muhammad Usman Commented May 6, 2018 at 13:43
Add a ment  | 

2 Answers 2

Reset to default 7

DOM manipulation is synchronous, however, the browser's re-rendering of the page in response to a DOM update is asynchronous. This can give the illusion of an asynchronous DOM update.

No, they don't do any long-running stuff in the background that would require notifying you when it is ready. They directly manipulate the DOM tree. You can also infer this from the fact that there are no callbacks involved.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论