third-party-web icon indicating copy to clipboard operation
third-party-web copied to clipboard

Highlight third parties with unload event handlers?

Open KenjiBaheux opened this issue 3 years ago • 3 comments

Would it be possible to highlight third parties that still rely on unload event handlers?

Those break the back/forward cache on some browsers, and are unreliable on other browsers or mobile platforms. There are better alternatives available which don't have these downsides (e.g. visibilitychange). More details in this lighthouse issue.

We did a large outreach to increase awareness and successfully convince lots of third parties to migrate away from unload event handlers, but there is still a long tail of third parties... Perhaps, thirdpartyweb could help raise awareness at scale?

Here is a query that should give a list of unload event handler sources:

SELECT COUNT(*) AS CNT, unload_source, unload_line, unload_column 
FROM `httparchive-lighthouse.BestPractices.unload_sources`
GROUP BY unload_source, unload_line, unload_column 
ORDER BY CNT DESC LIMIT 1000;

KenjiBaheux avatar May 27 '22 08:05 KenjiBaheux

Thanks for filing @KenjiBaheux :)

Always happy to consider additional perf impact of 3Ps! While we're shifting from 1->n metrics, network bytes is another stat we've been wanting to surface for a while too.

Getting the data should be the easy part, new visualizations / presentation / exploration is the harder part. If you have any idea in mind for the best way to structure this more complex perf story of 3Ps, it'd be much appreciated! 3x metrics across every 3P probably isn't scaling well in the markdown file anymore 😅

patrickhulce avatar May 27 '22 14:05 patrickhulce

From a perf angle:

  • it only takes one unload handler to block the BFCache from doing its thing. So, the performance cost goes far beyond the cost of a particular 3P.
  • It's essentially triggering a normal page load (albeit warm) instead of a near-instant restoration from the BFCache (a copy in memory).
  • On Chrome, this could negatively impact up to 1 in 5 (Android) or 1 in 10 (desktop platforms) navigations (source).
  • I wonder if there is data available to characterize the missed opportunity (e.g. representative CWV values for back/forward navigations for a given site or overall)?

KenjiBaheux avatar May 30 '22 07:05 KenjiBaheux

Thanks for those additional data points! Apologies for the miscommunication @KenjiBaheux I'm already super clear on the perf impact, only the UI/UX/presentation of this data is a blocker from my perspective. I'll need to find time to think about it (and anyone else is very welcome to jump in here! 🎉 )

patrickhulce avatar May 31 '22 14:05 patrickhulce