Challenge 3: Build a Facade for an Embedded Video — Possible Solution ====================================================================
Play video
WHY THIS WORKS -------------- - The initial page load only includes a plain (the thumbnail) and a small inline button — NOTHING resembling the actual YouTube player's JavaScript, iframe, or related scripts is present in the DOM or downloaded at all until the user actually clicks. This is the entire point of the facade pattern: the expensive third-party resource is never loaded for the (likely large) fraction of visitors who never click play, exactly addressing the chapter's point about third-party scripts being an easy-to-overlook INP cost. - width="800" height="450" on the thumbnail image reserves the correct space immediately (Chapter 3's CLS principle) — when the iframe eventually replaces it with the SAME width/height, no layout shift occurs, since the reserved space was already correctly sized from the very first render. - The click handler creates the real