From b53b12ff8cf33fb92592d0fc135db53964c68614 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 24 Mar 2015 23:33:32 +0000 Subject: [PATCH] Emoji: Instead of loading the emoji JS files automatically, we now include a small JS shim in the header, to test if the user's browser needs Twemoji. It then loads the emoji JS files only if they're needed. Props pento, azaozz. Fixes #31701. Built from https://develop.svn.wordpress.org/trunk@31875 git-svn-id: http://core.svn.wordpress.org/trunk@31854 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 1 + wp-includes/formatting.php | 69 ++++++++++++++++- wp-includes/js/wp-emoji-loader.js | 76 +++++++++++++++++++ wp-includes/js/wp-emoji-loader.min.js | 1 + wp-includes/js/wp-emoji-release.min.js | 4 + wp-includes/js/wp-emoji.js | 100 ++++++++++--------------- wp-includes/js/wp-emoji.min.js | 2 +- wp-includes/script-loader.php | 23 ------ wp-includes/version.php | 2 +- 9 files changed, 192 insertions(+), 86 deletions(-) create mode 100644 wp-includes/js/wp-emoji-loader.js create mode 100644 wp-includes/js/wp-emoji-loader.min.js create mode 100644 wp-includes/js/wp-emoji-release.min.js diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 69905be1c3..449d971cb8 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -213,6 +213,7 @@ add_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); add_action( 'wp_head', 'locale_stylesheet' ); add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); add_action( 'wp_head', 'noindex', 1 ); +add_action( 'wp_head', 'print_emoji_detection_script', 7 ); add_action( 'wp_head', 'wp_print_styles', 8 ); add_action( 'wp_head', 'wp_print_head_scripts', 9 ); add_action( 'wp_head', 'wp_generator' ); diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index f14ef866db..e6f44c851e 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -4082,6 +4082,13 @@ function wp_spaces_regexp() { * @since 4.2.0 */ function print_emoji_styles() { + static $printed = false; + + if ( $printed ) { + return; + } + + $printed = true; ?>