InfoPhilicWordPressTips to Speed Up WordPress Performance

Tips to Speed Up WordPress Performance

Hello guys, today I am going to share some tips to speed up WordPress Performance. Blog loading speed is an essential factor in getting more visitors and getting good rank in Google. Most of the time user comes to your blog and left it due to load time. It will ultimately increase the bounce rate on your blog.

Before you make any changes, I advise you to check your blog speed using online services. Once you have done with the pre-test, start modifying for more speed so that you can identify which configuration gives the best performance on your server.

How To Speed Up WordPress

Enabling Gzip compression

It will compress the HTML and CSS and will improve the page loading speed and reduces bandwidth usage.
The setup is different from one server to another so you may have to look on your host instructions section to see how you can enable it on your site.

## BEGIN Enable GZIP Compression ##

<IfModule mod_deflate.c>
   AddOutputFilterByType DEFLATE text/plain
   AddOutputFilterByType DEFLATE text/html
   AddOutputFilterByType DEFLATE text/xml
   AddOutputFilterByType DEFLATE text/css
   AddOutputFilterByType DEFLATE application/xml
   AddOutputFilterByType DEFLATE application/xhtml+xml
   AddOutputFilterByType DEFLATE application/rss+xml
   AddOutputFilterByType DEFLATE application/javascript
   AddOutputFilterByType DEFLATE application/x-javascript
   AddOutputFilterByType DEFLATE application/x-httpd-php
   AddOutputFilterByType DEFLATE application/x-httpd-fastphp
   AddOutputFilterByType DEFLATE image/svg+xml
   SetOutputFilter DEFLATE
</IfModule>

## END Enable GZIP Compression ##

Set the Leverage Browser Caching

By setting this, you’ll tell your visitors browsers to remember (caching) some of your website resources that you don’t change so often (like the logo or the CSS/js libraries, posted images, etc.) and only refresh them after a defined period.
To set it, you have to add something like this to your .htaccess file. Add the following code to the .htaccess file.

The setup may differ based on what resources you want to include.

## BEGIN Leverage Browser Caching ##

<IfModule mod_expires.c>
   ExpiresActive On
   ExpiresByType image/jpg "access plus 1 year"
   ExpiresByType image/jpeg "access plus 1 year"
   ExpiresByType image/gif "access plus 1 year"
   ExpiresByType image/png "access plus 1 year"
   ExpiresByType text/css "access plus 1 month"
   ExpiresByType application/pdf "access plus 1 month"
   ExpiresByType text/x-javascript "access plus 1 month"
   ExpiresByType application/x-shockwave-flash "access plus 1 month"
   ExpiresByType image/x-icon "access plus 1 year"
   ExpiresDefault "access plus 2 days"
</IfModule>

## END Leverage Browser Caching ##

Set Vary: Accept-Encoding Header

## BEGIN Vary: Accept-Encoding Header ##

<IfModule mod_headers.c>
   <FilesMatch "\.(js|css|xml|gz)$">
      Header append Vary: Accept-Encoding
   </FilesMatch>
</IfModule>

## END Vary: Accept-Encoding Header ##

Optimize images

If your blog has more pictures, it will reduce your server response time as the user have to download all the images each time they access your pages. To reduce the size of the images, you need to compress and optimize your images. It will aid to increase blog loading speed.

There are various plugins available to Compress and optimize images in the WordPress plugin repository. Some of the useful plugins are listed below:

After that put the following code at the bottom of your theme’s functions.php file.

add_filter( 'jpeg_quality', create_function('', 'return 50;' ) );

This code will automatically compress each thumbnail to 50%. You can change value 50 as per your need. For me, 50% gives the best performance. You can use Thumbnails regenerator plugin to regenerate all thumbnails after adding code in functions.php file located in the theme’s directory.

Lazy Load Images

There are many lazy load plugins available among them; Lazy Load is my favorite one. It uses jQuery.sonar to only load an image when it’s visible in the viewport.

Prevent Image Hotlinking

Image hotlinking is a term where someone can load images from your server to websites. In simple language, when someone put your image link on their content then that image loads from your server on their website. It will add unnecessary increase load on your server. So it’s good to prevent image hotlinking.

Add code to your .htaccess file to prevent image hotlinking:

# Start Hotlink protection

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^(http(s)?://)?(www\.)?yourdomain.com [NC]
RewriteCond %{HTTP_REFERER} !^(http(s)?://)?(www\.)?facebook\.com [NC]
RewriteCond %{HTTP_REFERER} !^(http(s)?://)?(www\.)?google\.*$/.* [NC]
RewriteCond %{HTTP_REFERER} !^(http(s)?://)?(www\.)?pinterest\.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,R,L]

Don’t forget to replace yourdomain.com with yours.

Use Lightweight Framework

In simple language, a framework is a package made up of a structure of files and folders of standardized code. It supports the development of websites, as a basis to start building a site.

Driving a WordPress site means, you need a robust framework or a theme. Each theme has a different code, and because of that, they are better than others. Sometimes these themes or frameworks are getting so bulky and thus leads to the bad performance of the site.

There are lots of themes or frameworks available for WordPress. But, while purchasing, make sure the theme is lightweight and also consider their upcoming features.

Remove Query Strings from Static Resources

It is a good idea to remove query strings from the static resources as it cause caching issues with some proxy cache and CDN. To remove query strings, add the following code at the bottom of the functions.php file located in theme’s directory.

// BEGIN Remove Query Strings

function _remove_script_version( $src ){
  $parts = explode( '?ver', $src );
  return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

// END Remove Query Strings

Remove Query Strings doesn’t affect the loading time nor the page scores anymore.

Use a cache plugin

Cache plugin generates static files of your content and serves them to the user whenever the user access your pages/posts. It will dramatically reduce server response time. I use WP-Rocket cache plugin on my website.

Use Content Delivery Network (CDN)

CDN means a geographically distributed network of proxy servers. It offers spatially related service to users with high availability and high performance.

The main goal behind the designing of CDN networks is to resolve the issue known as Latency. It’s the annoying delay that occurs from the moment you request to load a web page to the moment its content appears onscreen.

This delay occurred by numerous factors, including the physical distance between you and that website’s hosting server. So, to reduce such latency, CDNs are used to minimize that physical distance and improve that rendering speed.

Disable Pingbacks and Trackbacks

Pingbacks and trackbacks are WordPress’s core feature that allows you to keep eyes on those who have linked to your content. Though it is a cool feature, it slows down your site, so it’s better to disable it.

You can disable it by unchecking the pingbacks and trackbacks checkbox under the discussion settings.

Disable Trackbacks and Pingbacks
Disable Trackbacks and Pingbacks

This will only stop pingback and trackbacks for new posts. Read our detailed guide to bulk disable pingbacks and trackbacks on old articles.

Fix The admin-ajax.php Slow Problem

WordPress uses WP Heartbeat API to communicate between the server and the user’s web browser. The WP Heartbeat API uses admin-ajax.php calls to deliver with a web browser. AJAX calls are not cacheable and may increase WordPress server load time.

You can use Heartbeat Control plugin, which efficiently manages the frequency of the WordPress heartbeat API. Read our detailed guide to reduce admin-ajax server load in WordPress.

Choose Reliable Hosting

The main goal of hosting is to allow individuals and organizations to make their website accessible via the World Wide Web.

Choosing a reliable and fast web hosting is essential while driving a website. Although it manages your data 24*7. Generally, cheap things attract people more. But, while choosing the best host, I recommend don’t get excited by hosting providers that offer affordable services. Although, you will get, what you paid for.

To ease the task of choosing the best hosting, we have created a list of best-managed WordPress hosting.

Conclusion

So, this is all about speeding up WordPress performance. You have to make some changes in .htaccess and functions.php file to get excellent performance. Reduce HTTP requests to speed up your WordPress blog. You can use plugins to improve speed, but I would recommend you to use less number of plugins on your WordPress blog.

You'll also like:
Continue to the category
Amit Malewar
Amit Malewarhttps://www.infophilic.com/
Amit Malewar has been the tutorial writer since 2013. His passion for helping people in all aspects of technology flow through the expert coverage he provides. In addition to writing for InfoPhilic, Amit loves to read and try new things.

Comment Policy: Your words are your own, so be nice and helpful if you can. Please, only use your real name and limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please.

2 COMMENTS
  1. Where do i have to add leverage browser caching and cache header in .htacess file??
    After the end of wordpress or before the end of wordpress??
    Because i have set it after end of wordpress and it seems not working.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

GET STARTED
POPULAR NOW

How to Calibrate battery on your android device

For smartphone users, battery problems are the biggest concern. So to overcome this problem I am writing this short tutorial to calibrate battery. Battery issue...
DEALS

WP Rocket

Get 30% discount on WP Rocket plugin Now!
spot_img