How to Load wp-emoji-release.min.js to CDN in WordPress


While you’re optimizing your website, you probably encounter this little code wp-emoji-release.min.js from loading to your website and not loading to your CDN network. (A CDN is use to load all of your static file to other network/server in order for your server to reduce load and cater more visitor to your site than usual.). And there are no options in wordpress to change it links easily.

The last sort option you have is to remove this plugin in order to fully optimize your website. But, there are ways to still use wordpress emoji to load it to a CDN network.

If you’re using Wp Super Cache or Google Pagespeed, it has tool to filter out link and convert it to a cdn link. But The wp-emoji-release.min.js doesn’t automatically converted to a cdn link because the URL is being strip by the include_url() function of wordpress adding a \ on every slash.

To achieve it, we can manually edit the wordpress file. This is by editing the wp-includes/formatting.php file and edit the line 5085 – then change it to your CDN link.

BEFORE:

 $settings['source'] = array(
 /** This filter is documented in wp-includes/class.wp-scripts.php */
 'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ),
 );

AFTER:

 $settings['source'] = array(
 /** This filter is documented in wp-includes/class.wp-scripts.php */
 'concatemoji' => apply_filters( 'script_loader_src', "https://yourcdn.com/wp-includes/js/wp-emoji-release.min.js?$version", 'concatemoji' ),
 );

This is not the best solution, but if you have a better one. Please leave comment down below.

Comments 0

Your email address will not be published. Required fields are marked *

How to Load wp-emoji-release.min.js to CDN in WordPress

log in

Captcha!

reset password

Back to
log in
Choose A Format
Gif
GIF format