/** * Desactivar feeds de etiquetas (tags) para ahorrar crawl budget */ add_action('template_redirect', function() { if (is_feed() && is_tag()) { wp_die(__('Los feeds de etiquetas están desactivados.'), '', ['response' => 410]); } }); /** * Opcional: eliminar el link de feed de etiquetas del
*/ add_action('wp_head', function() { if (is_tag()) { remove_action('wp_head', 'feed_links_extra', 3); } }, 1);/** * Diferir carga de JavaScript para evitar bloqueo de renderización */ add_filter('script_loader_tag', function($tag, $handle) { // Excluir jQuery core para evitar romper dependencias $excluir = ['jquery-core', 'jquery-migrate']; if (in_array($handle, $excluir)) { return $tag; } if (strpos($tag, 'defer') === false) { $tag = str_replace(' src', ' defer src', $tag); } return $tag; }, 10, 2); /** * Precargar fuentes de Google de forma asíncrona */ add_filter('style_loader_tag', function($html, $handle, $href) { if (strpos($href, 'fonts.googleapis.com') !== false) { $html = " "; } return $html; }, 10, 3);add_filter('style_loader_tag', function($html, $handle) { if (strpos($handle, 'font') !== false || strpos($html, 'fonts.googleapis.com') !== false) { $html = str_replace("rel='stylesheet'", "rel='preload' as='style' onload=\"this.onload=null;this.rel='stylesheet'\"", $html); } return $html; }, 10, 2);