Disable emojis in WordPress without a plugin
Remove the WordPress emoji script and styles with a few lines of code. The Snipfire snippet covers almost everything the Disable Emojis plugin does.
What Disable Emojis (GDPR friendly) does
Disable Emojis removes the emoji script, styles and related code that WordPress loads for older browsers. The plugin on WordPress.org
What the snippet does the same
- The emoji detection script and emoji styles no longer load, on the site or in the admin.
- Emoji in feeds and emails are no longer swapped for images.
- There is no DNS prefetch to the WordPress.org emoji server, and emoji still show in every current browser.
What's different
- The plugin also removes the emoji add-on from the classic editor (TinyMCE). The snippet doesn't, which only matters if you write in the classic editor.
When to keep the plugin Keep the plugin if you write in the classic editor and want its emoji add-on gone too.
The snippet: Remove the emoji script and styles
Stops WordPress from loading its emoji script and styles on every page. Every current browser shows emoji on its own.
<?php
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_emoji_styles' );
remove_action( 'admin_enqueue_scripts', 'wp_enqueue_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' );
// No DNS prefetch for the emoji images either.
add_filter( 'emoji_svg_url', '__return_false' );
Notes, where it runs and what it was tested with
Switching from the plugin
- Install the snippet in Snipfire (it arrives switched off).
- Deactivate Disable Emojis (GDPR friendly).
- Switch the snippet on. Snipfire checks the code and test-loads your site first.
- Check the page it affects, then delete the plugin.