Skip to content

Conversation

@paulirish
Copy link
Member

@paulirish paulirish commented Oct 6, 2025

ancestor listener logic

#16292 made crawlable-anchors audit more lenient by allowing the 'placeholder anchors' which are called out in the HTML spec. previously LH would say "hey you are misusing anchors!" but.. now we started allowing them.

The logic was:

  • Potentially Placeholder == href-less <a> and and also not using target/download/ping/rel/type/hreflang/referrerpolicy.
  • Definitely placeholder == potentially placeholder && has event listeners on itself or ancestors
  • Not placeholder == potentially placeholder but has no event listeners.

The event listeners wasn't just the DOM node's event listeners but also its ancestors too. Also ALL types of listeners were considered. Which kinda sucks because any listener installed on <body> counts.. like idleness detection scripts or basically everything if a site uses event delegation.

Anyway. given that, the ancestor listener check yields results like 95% of the time. even tho they probably dont have much to do with the specific anchor's use.

perf

Separate from all this, the perf of this gatherer got a lot slower from this change. See #16704. And the ancestor checks are to blame. I did make it significantly faster but.. in the end, its not worth it to use this low-quality signal to help flag anchors that don't point to crawlable destinations.

Removing ancestor listeners sped things up quite a bit. on cnn.com homepage.. before we had 8,762 CDP calls for 'DOM.pushNodeByPathToFrontend', 'DOM.resolveNode', and 'DOMDebugger.getEventListeners' (each). Now, that number is just 551.

Getting that data took 4400ms, now it takes 160ms.

driveby: generate-timing-trace on html reports

the generate timing trace script can now handle a HTML report too.


fix #16704
partial revert of #16292

@paulirish paulirish requested a review from a team as a code owner October 6, 2025 23:26
@paulirish paulirish requested review from connorjclark and removed request for a team October 6, 2025 23:26
Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL at test failures

@paulirish paulirish merged commit c94a9d2 into main Oct 7, 2025
38 of 39 checks passed
@paulirish paulirish deleted the anchor-elem-perf branch October 7, 2025 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

anchor elements gatherer slowed down

3 participants