From 7e6107aad7e689a3de15d6787de85bf4497bc8bc Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 30 Jan 2025 17:37:02 +0000 Subject: [PATCH] PERF: Remove old fullscreen-detection code (#31075) This code was calling `elementFromPoint` on every scroll event. This is an expensive browser API, and also seems to trigger a premature 'paint' event during initial render. This seems to trigger cumulative-layout-shift metric problems, even though the shift was never actually visible onscreen. This workaround was added more than 7 years ago, and it seems like `document.fullscreenElement` now correctly detects fullscreen youtube embeds. So we should be able to remove the `elementFromPoint` call without affecting any functionality. --- .../discourse/app/components/scrolling-post-stream.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/scrolling-post-stream.js b/app/assets/javascripts/discourse/app/components/scrolling-post-stream.js index 6d65652048f..cb9572fbd78 100644 --- a/app/assets/javascripts/discourse/app/components/scrolling-post-stream.js +++ b/app/assets/javascripts/discourse/app/components/scrolling-post-stream.js @@ -67,16 +67,6 @@ export default class ScrollingPostStream extends MountWidget { return; } - // We use this because watching videos fullscreen in Chrome was super buggy - // otherwise. Thanks to arrendek from q23 for the technique. - const topLeftCornerElement = document.elementFromPoint(0, 0); - if ( - topLeftCornerElement && - topLeftCornerElement.tagName.toUpperCase() === "IFRAME" - ) { - return; - } - const windowHeight = window.innerHeight; const slack = Math.round(windowHeight * 5); const onscreen = [];