javascriptdomeventsw3c

What does mean Sync/Async in event table


I came across an interesting table of events at https://www.w3.org/TR/uievents. However, I am not familiar with the category Sync / Async.

Event Type Sync / Async Bubbling Phase Trusted event target types DOM Interface Cancelable Default Action
click Sync Yes Element PointerEvent Yes Varies: for targets with an associated activation behavior, executes the activation behavior; for focusable targets, gives the element focus.
error Async No Window, Element Event No None
input Sync Yes Element InputEvent No None
load Async No Window, Document, Element Event No None
mouseover Sync Yes Element MouseEvent Yes None
mouseup Sync Yes Element MouseEvent Yes None
select Sync Yes Element Event No None
unload Sync No Window, Document, Element Event No None
wheel Async Yes Element WheelEvent Yes Scroll (or zoom) the document

Could someone please explain what this category means?

For example: what is the difference between the Sync click event and the Async wheel event?


Solution

  • There used to be a section explaining this, you can still see it in the previous edition of the same document.

    It reads

    Events may be dispatched either synchronously or asynchronously.

    Events which are synchronous ("sync events") are treated as if they are in a virtual queue in a first-in-first-out model, ordered by sequence of temporal occurrence with respect to other events, to changes in the DOM, and to user interaction. Each event in this virtual queue is delayed until the previous event has completed its propagation behavior, or been canceled. Some sync events are driven by a specific device or process, such as mouse button events. These events are governed by the event order algorithms defined for that set of events, and user agents will dispatch these events in the defined order.

    Events which are asynchronous ("async events") may be dispatched as the results of the action are completed, with no relation to other events, to other changes in the DOM, nor to user interaction.

    [EXAMPLE 3] During loading of a document, an inline script element is parsed and executed. The load event is queued to be fired asynchronously at the script element. However, because it is an async event, its order with relation to other synchronous events fired during document load (such as the DOMContentLoaded event from [HTML5]) is not guaranteed.

    It has been removed along with its parent section as part of https://github.com/w3c/uievents/issues/372, which makes the point that the parent section is already mainly covered by the DOM specs. However it's true that the specific bit about sync/async isn't there either and thus this concept isn't backed by anything anymore.

    I added a comment on the issue to let them know about it.