Tips to Speed Up WordPress Performance

0
Make WordPress Blog Faster

Hello guys, today I am going to share some tips to speed up WordPress Performance. Blog loading speed is an important factor to get more visitors and get good rank in the Google. Most of the time user comes to your blog and left it due to load time. This ultimately increases 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:

1. Enabling Gzip compression

This will compress the HTML and CSS and will improve the page loading speed and reduces the 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 ##

2. 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 of time.
To set it, you have to add something like this to your .htaccess file. Add the following code to the .htaccess file.

NOTE: 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 ##

3. 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 ##

4. Optimize images

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

To Compress and optimize images there are various plugins available in WordPress plugin repository. Some of the good 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 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 theme’s directory.

5. 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.

6. 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 own content then that image loads from your server on their website. This adds 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]

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

7. Use Lightweight Framework

Describing in simple, a framework is defined as 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 solid framework or a theme. Each theme is coded differently 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.

7. 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 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 ##

8. Use a cache plugin

Cache plugin generates static files of your content and serves them to the user whenever user access your pages/posts. This dramatically reduces server response time. I personally use WP-Super Cache plugin on my website.

9. Use Content Delivery Network (CDN)

CDN means a geographically distributed network of proxy servers. It offers spatially relative 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 actually 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.

10. Disable Pingbacks and Trackbacks

This is 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.

11. Fix The admin-ajax.php Slow Problem

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

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

12 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 attracted by hosting providers that offer cheap services. Although, you will get, what you paid for.

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

Conclusion

So, is this all about speeding up WordPress performance. You have to make some changes in .htaccess and functions.php file to get good 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.