14 Ways to Improve WordPress Performance Without Plugins.

Although the WordPress core is not large, the themes and plugins you use may slow down the total page load time. There are several ways to improve WordPress performance.

For Example:

  • Using CDN (Content Delivery Network)
  • Leveraging browser & server caching
  • Hosting on a performance-optimized server
  • Using a lightweight theme

However, did you know that there are many features in the WordPress core that you may not use and that removing them might save a few bytes and make the website load faster?

The following can be done in two ways, first, by using some plugin, and second, by adding a few lines of code in functions.php. If anything can be done with code addition/modification in an existing file, I prefer not to use a plugin.

Best Practice

Make a backup of the file you’re about to change so you can roll back fast if something goes wrong.

All the below codes are to be added in functions.php unless specified differently.

If you have analyzed your website for load time, then you might have come across a recommendation to eliminate query strings from static resources (CSS, JS files).

image source:- geekflare

Because query strings in files may prevent CDN’s from caching files, you may not be taking advantage of all the caching benefits available.

Add the following code to remove the query strings.

function remove_cssjs_ver( $src ) {
if( strpos( $src, '?ver=' ) )
 $src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );

2. Remove RSD Links

If you want to use an XML-RPC client, pingback, etc., you’ll need to use RSD (Really Simple Discovery). However, if you don’t need pingback or a remote client to manage posts, then get rid of this unnecessary header by adding the following code.

remove_action( 'wp_head', 'rsd_link' ) ;

We listed many Cloud hosting companies’ plans

  • Malware Protection.
  • Free SSL Certificates.
  • cPanel Control Panel.
  • Daily Backups.
  • 2 GB memory.
  • 24/7 Technical Support.
Check Out!

3. Disable Emoticons

Remove extra code from WordPress that was recently introduced to support emoticons on an older browser.

remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );

4. Remove Shortlink

Since version 3, WordPress has included a short link (a shortened form of the web page address) in the header code. For ex:

<link rel='shortlink' href='https://hostguid.com/?p=187' />

If you’re not using short links for anything, you may remove them by adding the code below.

remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);

5. Disable Embeds

In WordPress 4.4, the oEmbed function was added, which allows any site to remotely embed WordPress posts, and it looks like this.

The following code will prevent anyone from embedding your blog post and prevent related JS files from loading.

function disable_embed(){
wp_dequeue_script( 'wp-embed' );
}
add_action( 'wp_footer', 'disable_embed' );

6. Disable XML-RPC

Do you need to publish/edit/delete a post, edit/list comments, or submit a file using the WordPress API (XML-RPC)? Having XML-RPC enabled but not adequately protected can also lead to DDoS and brute force attacks.

If you don’t need then disable it by adding below.

add_filter('xmlrpc_enabled', '__return_false');

7. Hide WordPress Version

This doesn’t help in performance but more to mitigate information leakage vulnerability. WordPress includes a meta-name generator with the reports provided by default, which is available in the source code and HTTP header.

Add the code below to delete the WordPress version.

remove_action ( 'wp_head', 'wp_generator' ) ;

8. Remove WLManifest Link

Do you utilize Windows Live Writer’s tagging support? If not, add it in the box below.

remove_action( 'wp_head', 'wlwmanifest_link' ) ;

We listed many WordPress hosting companies’ plans

  • Free Domain.
  • Cloudflare CDN.
  • Free SSL.
  • Daily Backups.
  • 99.9% Uptime Guarantee.
  • 24/7 Technical Support.
Check Out!

9. Remove JQuery Migrate

WordPress added JQuery migration from version 3.6. This is not needed if you are using the latest version of JQuery and themes/plugins are compatible with it. To remove jquery-migrate.min.js from loading, add the below code.

function deregister_qjuery() { 
 if ( !is_admin() ) {
 wp_deregister_script('jquery');
 }
} 
add_action('wp_enqueue_scripts', 'deregister_qjuery');

10. Disable Self Pingback

I don’t know why you need the self-pingback details on your blog post and I know it’s not just I get annoyed. If you are, the code below will help you.

function disable_pingback( &$links ) {
 foreach ( $links as $l => $link )
 if ( 0 === strpos( $link, get_option( 'home' ) ) )
 unset($links[$l]);
}
add_action( 'pre_ping', 'disable_pingback' );

11. Disable or Limit Post Revisions

WordPress post revisions aren’t new, and they’re useful for restoring a post if the browser crashes or the network goes down. But ask yourself, how many times did it happen?

By default, WordPress saves revisions for each draft or published article, which can cause the database to become bloated. You may either choose to disable it entirely or limit the number of revisions to be saved.

Add the following in wp-config.php file

To disable post revisions

define('WP_POST_REVISIONS', false);

To limit the number

Let’s say you only keep two revisions.

define('WP_POST_REVISIONS', 2);

Note: This must be above the ABSPATH line else it will not work.

WordPress-Care-Maintenance

12. Disable Heartbeat

WordPress uses heartbeat API to communicate with a browser to a server by frequently calling admin-ajax.php. If you’re using shared hosting, this may slow down the total page load time and increase CPU use.

If you don’t need the heartbeat API, you can turn it off by adding the code below.

add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}

13. Disable Dashicons on Front-end

Dashicons are utilized in the admin console, and if not using them to load any icons on the front-end then you may want to disable it. By adding below,dashicons.min.css will stop loading on the front-end.

function wpdocs_dequeue_dashicon() {
        if (current_user_can( 'update_core' )) {
            return;
        }
        wp_deregister_style('dashicons');
}
add_action( 'wp_enqueue_scripts', 'wpdocs_dequeue_dashicon' );

14. Disable Contact Form 7 JS/CSS

Using Contact Form 7 and noticed their CSS/JavaScript files are getting loaded on every page? Well, you are not alone.

The good news is you can stop loading it with the below code.

add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );

Conclusion

The above will help to reduce a few HTTP requests and overall page size. All the codes are available on Github.

Join Our Telegram Group

Upcoming hosting and SSL offers and news updates here. We can try to solve your doubt regarding any problem like Domain, Hosting, SSL certificate, etc. And News update here.

This article helpful?
YesNo
Share your love
Default image
Host Guid
Articles: 105

Leave a Reply

Your email address will not be published.