w3c / w3c/element-timing

Clarify Element Timing's handling of pseudo-elements

Open
#74 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Bikeshed
Stars
61
Forks
19
Avg merge
1d 10h
Merged PRs (30d)
1

Description

The spec doesn't appear to say how Element Timing for pseudo-elements should be handled. A surprising number of sites put large content in pseudo-elements, so explicit support would be helpful for performance measurements and downstream specs like LCP.

Current browser behavior:

Chrome appears to be the only browser where support (or lack) is observable, but please correct me if I'm missing an entryType somewhere.

  • In Chrome, Element Timing will include timing for images in a background-image on a pseudo-element (example using a background image in ::after). The element property will be set to the originating element, but the intersectionRect, naturalWidth, naturalHeight, and url will all be for the actual image painted in the pseudo-element.

    This is perhaps the best that can be done, since it's not possible to have a JS reference to the pseudo-element itself. The image information in the entry is usually enough to figure out what exactly is being referred to, but an additional annotation somewhere to explicitly mark the entry as referring to a pseudo-element could be helpful for automated tools to know where to look.

  • Again in Chrome, Element Timing will not include timing for images in a more-or-less identical page but using content in a pseudo-element to add an image (example using content in ::after). As a result, the smaller text is determined to be the LCP element instead of the larger image.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Element Timing specification and the two linked browser examples for pseudo-element images. Determine how background-image and content in pseudo-elements should be specified, including whether entries need an explicit pseudo-element annotation; done means the handling and observable entry data are unambiguous for downstream specs such as LCP.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation, performance
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.