0

If we want a callback while the user clicks a button, we just simply type
btn.addEventListener('click', callback)

The question I want to figure out is this: how can it work? How to do that?

Did the browser add a thread that continued checking for it (that's obviously not the case, since it consumes lots of resources).

Or did the browser inside use some kind of server push-technology or something else?

1 Answer 1

1

To simplify the description, let's just say the browser has a general "mouse click event" on it's whole application canvas, then figures out which element on the screen is at that position and fires the appropriate click event for that element.

Here's an article about WebKit internals that goes more in details on how browsers parse, DOM, events, etc...

Is that what you are looking for? What exactly are you trying to accomplish?

Hope this helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.