Make WordPress Core

Opened 8 years ago

Closed 5 years ago

Last modified 10 months ago

#35498 closed enhancement (maybelater)

Add a filter to enable twemoji all the time

Reported by: iseulde's profile iseulde Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Emoji Keywords: needs-patch
Focuses: performance Cc:

Description

Regardless of browser support.

Change History (11)

#1 @iseulde
8 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to enhancement

#2 @peterwilsoncc
8 years ago

Such a filter could be used for disabling too, and return force_enable, disable (with the alias force_disable) or, the default, detect.

#3 @iseulde
8 years ago

Sure. The reason I want this is because I want my content to be the same regardless of the browser. Also then you don't need this chunk of inline JS in the head. But an easy way to disable would also be good! Not sure if there is right now.

#4 @voldemortensen
8 years ago

The simplest way I know of to disable currently is with this.


/**
 * Disable the emoji's
 */
function disable_emojis() {
        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_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( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
}
add_action( 'init', 'disable_emojis' );

/**
 * Filter function used to remove the tinymce emoji plugin.
 * 
 * @param    array  $plugins  
 * @return   array             Difference betwen the two arrays
 */
function disable_emojis_tinymce( $plugins ) {
        if ( is_array( $plugins ) ) {
                return array_diff( $plugins, array( 'wpemoji' ) );
        } else {
                return array();
        }
}

Taken from the disable-emojis plugin on the repo.

#5 @swissspidy
7 years ago

  • Component changed from General to Emoji

#6 @pento
5 years ago

  • Milestone Future Release deleted
  • Resolution set to maybelater
  • Status changed from new to closed

This can be done fairly easily without needing a special filter for it: remove the print_emoji_detection_script action, then load the wp-includes/js/wp-emoji-release.min.js file.

I'm going to close this ticket as maybelater: if there are additional difficulties which require a core solution, we can reopen it.

#7 follow-ups: @westonruter
2 years ago

I wonder should we now not disable emoji detection by default (along with the s.w.org dns-prefetch)? It seems all platforms now support emoji natively: https://caniemoji.com/

By disabling by default, this would eliminate emoji-loader.js from blocking the thread as it is currently causing a ~90ms long task (ref 37788#comment:4).

#8 @westonruter
2 years ago

  • Focuses performance added

#9 @seedsca
2 years ago

It seems all platforms now support emoji natively

I only see four platforms included on that link. Is Linux also not affected?considered?

#10 in reply to: ↑ 7 @pento
2 years ago

Replying to westonruter:

I wonder should we now not disable emoji detection by default (along with the s.w.org dns-prefetch)? It seems all platforms now support emoji natively: https://caniemoji.com/

That site doesn't tell the full story: the issue isn't about whether platforms support emoji natively, it's about what emoji version they support. As Twemoji usually add support for new emoji earlier than other platforms, we're frequently able to roll out rendering support for new emoji versions to display on devices that don't yet support that version.

So, I doubt it will ever be possible to disable emoji detection by default. Personally, I'd love to see this detection done by the UA, it'd be much better for everyone if we could just check window.navigator.emojiVersion instead of doing our own rendering test.

#11 in reply to: ↑ 7 @westonruter
10 months ago

Replying to westonruter:

By disabling by default, this would eliminate emoji-loader.js from blocking the thread as it is currently causing a ~90ms long task (ref 37788#comment:4).

I've opened #58472 to specifically address the long task.

Note: See TracTickets for help on using tickets.