diff --git a/Public/YoutubeFacade/Infrastructure/Services/YoutubeFacadeContentFilter.php b/Public/YoutubeFacade/Infrastructure/Services/YoutubeFacadeContentFilter.php
new file mode 100644
index 00000000..32f8b759
--- /dev/null
+++ b/Public/YoutubeFacade/Infrastructure/Services/YoutubeFacadeContentFilter.php
@@ -0,0 +1,54 @@
+renderer = $renderer;
+ }
+
+ /**
+ * Filter content to replace YouTube iframes with facades
+ *
+ * @param string $content Post content
+ * @return string Filtered content
+ */
+ public function filter(string $content): string
+ {
+ // Match YouTube iframes (with or without video-wrapper)
+ // Pattern handles both youtube.com/embed/ and youtube-nocookie.com/embed/
+ $pattern = '/
+HTML;
+
+ return $html;
+ }
+}
diff --git a/Public/YoutubeFacade/Infrastructure/Wordpress/YoutubeFacadeHooksRegistrar.php b/Public/YoutubeFacade/Infrastructure/Wordpress/YoutubeFacadeHooksRegistrar.php
new file mode 100644
index 00000000..d7a0afd4
--- /dev/null
+++ b/Public/YoutubeFacade/Infrastructure/Wordpress/YoutubeFacadeHooksRegistrar.php
@@ -0,0 +1,70 @@
+contentFilter = $contentFilter;
+ }
+
+ /**
+ * Register all hooks
+ */
+ public function register(): void
+ {
+ // Filter post content to replace YouTube iframes with facades
+ add_filter('the_content', [$this->contentFilter, 'filter'], 20);
+
+ // Enqueue facade assets
+ add_action('wp_enqueue_scripts', [$this, 'enqueueAssets'], 15);
+ }
+
+ /**
+ * Enqueue CSS and JS for YouTube facades
+ */
+ public function enqueueAssets(): void
+ {
+ // Only on single posts where videos might appear
+ if (!is_single()) {
+ return;
+ }
+
+ wp_enqueue_style(
+ 'roi-youtube-facade',
+ get_template_directory_uri() . '/Public/YoutubeFacade/Infrastructure/Ui/Assets/Css/youtube-facade.css',
+ [],
+ ROI_VERSION,
+ 'all'
+ );
+
+ wp_enqueue_script(
+ 'roi-youtube-facade',
+ get_template_directory_uri() . '/Public/YoutubeFacade/Infrastructure/Ui/Assets/Js/youtube-facade.js',
+ [],
+ ROI_VERSION,
+ [
+ 'in_footer' => true,
+ 'strategy' => 'defer',
+ ]
+ );
+ }
+}
diff --git a/functions.php b/functions.php
index 908289bb..d81e9d2b 100644
--- a/functions.php
+++ b/functions.php
@@ -156,6 +156,17 @@ try {
);
$themeSettingsInjector->register();
+ // === YOUTUBE FACADE (PageSpeed Optimization Phase 2.4) ===
+ // Lazy-load YouTube iframes to reduce TBT by ~2000ms
+ $youtubeFacadeRenderer = new \ROITheme\Public\YoutubeFacade\Infrastructure\Ui\YoutubeFacadeRenderer();
+ $youtubeFacadeFilter = new \ROITheme\Public\YoutubeFacade\Infrastructure\Services\YoutubeFacadeContentFilter(
+ $youtubeFacadeRenderer
+ );
+ $youtubeFacadeHooksRegistrar = new \ROITheme\Public\YoutubeFacade\Infrastructure\Wordpress\YoutubeFacadeHooksRegistrar(
+ $youtubeFacadeFilter
+ );
+ $youtubeFacadeHooksRegistrar->register();
+
// Log en modo debug
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('ROI Theme: Admin Panel initialized successfully');