'remove_dns_prefetch', 'title' => 'Remove emoji server DNS prefetch', 'desc' => 'Remove the dns-prefetch hint for the WordPress.org emoji server', 'icon' => 'rss', 'help' => 'Older WordPress versions added a dns-prefetch hint for the WordPress.org server that hosts emoji images. WordPress 7.1 no longer adds it, so on an up-to-date site this feature usually changes nothing. It removes any dns-prefetch hint for that server that goes through WordPress\'s resource hints, whoever added it.', 'before' => 'A dns-prefetch link to the WordPress.org emoji server in the page head (older WordPress versions)', 'after' => 'Hint removed.', 'benefit' => 'A dns-prefetch hint only asks the browser to look up an address early; it does not download anything. Removing it saves at most one DNS lookup, and only matters if emoji images are never loaded from that server.', 'level' => 'beginner', 'audience' => 'everyone', 'priority' => 4, 'detect' => function () { return array( 'detected' => true, 'message' => 'DNS prefetch hint for the WordPress.org emoji CDN in the page header', 'safe' => true, 'savings' => '1 DNS lookup', ); }, 'callback' => function () { add_filter( 'wp_resource_hints', function ( $urls, $type ) { if ( 'dns-prefetch' === $type ) { $urls = array_filter( $urls, function ( $url ) { return strpos( $url, 's.w.org' ) === false; // phpcs:ignore PluginCheck.CodeAnalysis.Offloading.OffloadedContent -- Matches core's emoji CDN hint in order to remove it; nothing is loaded. } ); } return $urls; }, 10, 2 ); }, );