Spurious emoji-related prefetch

I noticed when doing a view source of a recent CP project, I saw this:

<link rel=‘dns-prefetch’ href=‘//twemoji.classicpress.net/’ />

There are no other references to this domain in the page, which begs two questions:

  1. Why is it there?
  2. How can I remove it?
2 Likes

I think it’s there to be able to call in emojis quickly. But if you dont use that, you can probably remove it. Though how to do that I am not completely clear on. Maybe @james can help and/or shed more light on this.

2 Likes

You can remove it using filters:

add_filter ( 'emoji_svg_url' , 'zigpress_kill_emoji' );
function zigpress_kill_emoji( $string ){
	return "";
};

Seems to work but needs to be tested better than I did.
Simone.

3 Likes

OK, I’ve found that filter in wp-includes and I can see how it works.

But I also have the following in my theme:

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’ );

which is intended to remove all emoji processing - I thought that would prevent the prefetch being output?

2 Likes

Try this:

add_filter('emoji_svg_url' , '__return_false');

It should work without setting a priority.

3 Likes

Yes, I can confirm that works.

3 Likes

But what’s bugging me is that I thought emojis were being removed from CP altogether? Or is that something for v2?

2 Likes

Good to hear. I had this same question back in my WP days … it does seem to take an awful lot of filters to fully remove emojis.

2 Likes

The idea to remove emojis received a lot of interest and it is planned for v2; see the note at the top of the petition. In the meantime, we’ll have to rely on the filters.

2 Likes

OK, thanks for clarifying, I’ve upvoted the petition.

And I’ve published a brief post to help people get the filters right if they’re interested.

4 Likes

A minor but important point: let’s be a little more accurate with our language please - we’re not removing emojiis, we’re moving them to a core plugin.

I’m sure everyone here knows what they mean, but someone new to CP won’t.

6 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.