About the operating mechanism of the browser, will all dom operations enter the message queue?

the following figure shows the operating mechanism of the browser

clipboard.png

have a few questions, please also advise:

1. Does DOM (document) refer to all dom related api?

document.querySelector("-sharptest")

2. If the above question is true, will it also enter the message queue (callback queue) after I look up a dom?

3. I understand that callback queue is a callback function queue. For example, after setTimeout (fn,100) is executed by the browser, fn will be placed in callback queue . If the above two questions are true, document.querySelector ("- sharptest") , which callback function is put in callback queue ?

also ask the great god to solve the doubt, thank you very much ~

Jan.21,2022

1 is not true. The word dom here means

.

DOM itself does not belong to js, which is an interface provided by the browser. You can do a lot of things in this interface, but if you listen for an event and need to execute a callback when the event is triggered, how do you execute the callback?

will be inserted into the task queue, waiting for execution. However, this task queue and setTimeout's task queue should not be the same, and may not be asynchronous. In fact, most event callbacks are Synchronize, but they are both in the task queue, except that there may be one or more task queues, and different queues have different priorities.

Video source: https://www.youtube.com/watch.

recent one: https://www.youtube.com/watch.

Menu