Skip to content

Synchronous layout-forcing APIs are not covered by any guideline #556

Open
@xiaochengh

Description

@xiaochengh

(Noticed when reviewing w3ctag/design-reviews#1043)

There exists a class of JS APIs that queries the up-to-date layout result, and if we don't have that, synchronously forces a layout to recompute it. These APIs are known to be easily misused and cause layout thrashing.

Examples include:
Element.offset*, Document.elementFromPoint(), ...

The current guidelines do not provide a guidance for these known troublemakers:

  • Be synchronous when appropriate says a API should be synchronously if "the execution time is short and deterministic", but these APIs can incur a long execution time.

  • Design asynchronous APIs using Promises says an API might need to be asynchronous if "the user agent may need to do a significant amount of work on another thread, or in another process, before returning the result", but these APIs do a significant amount of work on the same thread.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Performance

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions