Disable the emoji scripts
One less script on every page. Browsers render emoji natively anyway.
add_action( 'init', function() {
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' ); // WordPress before 6.4
remove_action( 'admin_print_styles', 'print_emoji_styles' ); // WordPress before 6.4
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' );
add_filter( 'emoji_svg_url', '__return_false' ); // No DNS prefetch to s.w.org
} );
Licensed under GPL-2.0-or-later, provided as is. Review and test it before using it on a live site.
How it works
WordPress adds a small detection script to every page, which loads wp-emoji-release.min.js and swaps emoji for images from s.w.org when a browser can’t draw them. Every current browser can, so the script only costs a request and some parsing. The snippet removes the script and styles on the front end and in wp-admin, stops emoji being turned into images in feeds and emails, and drops the DNS prefetch to s.w.org.
Compatibility
It covers both the current way WordPress loads emoji styles (wp_enqueue_emoji_styles, since 6.4) and the older one, so it works on any recent version.
How to check it works
View the source of any page and search for wp-emoji and s.w.org. Neither should appear. Emoji in your content still show, drawn by the browser.
How to undo it
Remove the code.
How to add this snippet
- Copy the code above.
- Paste it at the end of your child theme’s
functions.php, in Appearance → Theme File Editor or over FTP. - Save, then open the site and check that everything works. If something breaks, remove the code.
Need more than one? Open this snippet in the builder, turn on the others you want and copy them as one functions.php, or download them as a small plugin.
More in Performance
- Remove Gutenberg CSS on the front endFor sites built with Elementor or the classic editor.
wp_enqueue_scripts - Limit post revisionsKeeps the database from filling up with hundreds of old revisions.
wp_revisions_to_keep - Control the Heartbeat APIStops Heartbeat on the front end and slows it down in wp-admin. The post editor keeps it, so autosave and post locking still work.
heartbeat_settings