Compute Engine

7 Ways for a Lightweight WordPress with Best Performance

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

7 Ways for a Lightweight WordPress with Ultimate Performance. There are many tips out there to optimize the performance of your WordPress website.

Here are some unique methods to secure your website and disable some unwanted load on your website like

  • Disable Emoji
  • Remove Query Strings
  • Disable XML-RPC
  • Remove jQuery migrate
  • Remove Meta Generator Tags
  • Remove Manifest, RSD and Shortlinks
  • Disable Pingbacks
  • Disable Rest API Links
  • Disable Dashicons

Disable Emoji

Emoji’s are loaded on every page of your website. It’s actually loaded by a javascript file ( wp-emoji-release.min.js). You can remove Emoji with the following code.

add_action('init', 'disable_emojis');

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_filter('wp_resource_hints', 'disable_emojis_dns_prefetch', 10, 2);
add_filter('emoji_svg_url', '__return_false');
function disable_emojis_tinymce($plugins) {
if(is_array($plugins)) {
return array_diff($plugins, array('wpemoji'));
} else {
return array();
function disable_emojis_dns_prefetch( $urls, $relation_type ) {
if('dns-prefetch' == $relation_type) {
$emoji_svg_url = apply_filters('emoji_svg_url', '');
$urls = array_diff($urls, array($emoji_svg_url));
return $urls;

Remove Query Strings

Query strings such as ? or & are added by WordPress to every css and js files for versioning (?ver=5.0.2). You may get a warning about removing this while you do a speed test. Remove the query strings with the following code.

add_action('init', 'remove_query_strings');

function remove_query_strings() {
if(!is_admin()) {
add_filter('script_loader_src', 'remove_query_strings_split', 15);
add_filter('style_loader_src', 'remove_query_strings_split', 15);
function remove_query_strings_split($src){
$output = preg_split("/(&ver|\?ver)/", $src);
return $output[0];

Disable XML-RPC

XML-RPC is used for remote connections. For better security you can remove this from your WordPress.

add_filter('xmlrpc_enabled', '__return_false');
add_filter('wp_headers', 'remove_x_pingback');
add_filter('pings_open', '__return_false', 9999);

function remove_x_pingback($headers) {
unset($headers['X-Pingback'], $headers['x-pingback']);
return $headers;

Remove jQuery Migrate

Most latest WordPress themes and plugins won’t use jQuery migrate. In most cases it’s an unnecessary load to your website.

add_filter('wp_default_scripts', 'remove_jquery_migrate');

function remove_jquery_migrate(&$scripts) {
if(!is_admin()) {
$scripts->add('jquery', false, array( 'jquery-core' ), '1.12.4');

Remove Meta Generator Tags

By default a meta tag is added by WordPress with the version you are using. Why would you show your version of WP to everyone. Just remove it.

remove_action('wp_head', 'wp_generator');
add_filter('the_generator', 'hide_wp_version');

function hide_wp_version() {
return '';

Remove Manifest, RSD and Shortlinks

You can safely remove the manifest link if you are not using Windows Live Writer.

remove_action('wp_head', 'wlwmanifest_link');

RSD links are mostly unnecessary code.

remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action ('template_redirect', 'wp_shortlink_header', 11, 0);

If you are already using permalinks, then you don’t need the shortlinks.

remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action ('template_redirect', 'wp_shortlink_header', 11, 0);

Disable Pingbacks

Self Ping backs are simply nothing more a spam.

add_action('pre_ping', 'disable_self_pingbacks');

function disable_self_pingbacks(&$links) {
$home = get_option('home');
foreach($links as $l => $link) {
if(strpos($link, $home) === 0) {

Disable Rest API Links

Most sites don’t use these, and therefore it’s also just and unnecessary code.

remove_action('wp_head', 'rest_output_link_wp_head');
remove_action('template_redirect', 'rest_output_link_header', 11, 0);

Disable Dashicons

Dashicons is the official font used for icons by WordPress. If you don’t need dashicons you can remove this from your front end except all admin pages.

add_action('wp_enqueue_scripts', 'disable_dashicons');

function disable_dashicons() {
if(!is_admin()) {

Where do you add these codes?

You can add these codes to your child-theme’s functions.php file.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.