Remove the emoji detection script, inline styles and DNS prefetch WordPress adds to every page. Emojis still show using the visitor's own system font.
add_action( 'init', function (): void {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_emoji_styles' );
remove_action( 'admin_enqueue_scripts', 'wp_enqueue_emoji_styles' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
} );
// Remove the classic editor's emoji plugin.
add_filter( 'tiny_mce_plugins', function ( array $plugins ): array {
return array_diff( $plugins, [ 'wpemoji' ] );
} );
// Remove the DNS prefetch for the emoji CDN, whatever version it points to.
add_filter( 'wp_resource_hints', function ( array $urls, string $relation_type ): array {
if ( 'dns-prefetch' !== $relation_type ) {
return $urls;
}
return array_values( array_filter( $urls, function ( $url ): bool {
$href = is_array( $url ) ? ( $url['href'] ?? '' ) : (string) $url;
return ! str_contains( $href, 's.w.org/images/core/emoji' );
} ) );
}, 10, 2 );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
WordPress adds an emoji detection script, a block of inline CSS and a DNS prefetch to s.w.org on every page. They exist so very old browsers can show emoji as images. Every current browser and operating system draws emoji itself, so on most sites this is code that loads and does nothing.
The init callback removes each piece WordPress hooks in: the detection script on the front end and in wp-admin, the emoji styles (both the newer wp_enqueue_emoji_styles and the older print_emoji_styles), and the filters that turn emoji into images in feeds and emails. A second filter removes the wpemoji plugin from the classic editor.
The DNS prefetch is removed by matching the address rather than an exact URL. Older versions of this snippet compared against a hard-coded emoji version number, which stopped working as soon as WordPress updated its emoji set. Matching on s.w.org/images/core/emoji keeps working through every update.
Yes. Emoji in your posts are ordinary Unicode characters, and visitors’ devices draw them with their own emoji font. You only lose the image fallback for browsers that are many years out of date.
View the page source of your homepage and search for wp-emoji and s.w.org. Neither should appear. Then type an emoji into a post and check it still displays.