How to speed up WordPress sites? – Part 4

How to speed up Wordpress sites? - Part 4
How to speed up Wordpress sites? - Part 4

Vishal Kothari

This is the last part of the 4 part series on How to speed up WordPress sites. You can check Part 1, Part 2 & Part 3 if you haven’t already been through those.

In this post, we will be looking at some more ways to speed up Worpdress websites.

1. Use htaccess to compress data

.htaccess is a configuration file that is usually found in the root of your web domain or it could also reside in individual sub-folders. It can increase your website’s security. It can also significantly increase WordPress website load times.

Compression can be achieved using a number of plugins. In this post, we will be discussing how to achieve gzip compression with the .htaccess file.

This is how a default .htaccess file looks like in a WordPress installation:

# BEGIN WordPress

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /woo_vishal/index.php [L]

# END WordPress

To enable gzip compression, you need to add the below lines at the end of the file:

# compress text, html, javascript, css, xml:
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

The above will compress text, html, JavaScript, CSS & XML content.

You can test the result with your browser developer’s tool (inspector), or by using some online tools such as: HTTP Compression Test. Enter your site’s URL, and it will tell you if it is actually gzipped, and if it is, you will see the compression ratio.

Below you can see the results of compression on our own website: https://performancegurus.net .

URL Compression Test Results
URL Compression Test Results

The compressed page is 7 times smaller then the uncompressed one. This results in huge improvement in the loading time of the website.

2. Deactivate unused plugins

You may be using WordPress for your corporate blog, as a News website or for selling something. It’s safe to assume that any WordPress website has an average of 10 to 25 plugins at least. It may have more then that, but it’s unlikely that it will have fewer plugins. Just recently there was an article on WPMUDev. It mentioned that “The record for the most number of plugins installed on a WPMU DEV member’s WordPress site is 637.”. That’s a big number! 637 plugins! I was as surprised as you when I read it.

So it’s entirely possible to have more plugins. However, when you have plugins that are no longer being used, it then affects the load time of your website.

When any page of your WordPress website loads, it checks all the plugins that are active & loads all the necessary files within those plugins (depending on the structure of those plugins).

More often then not, you will always find a few plugins that you were using or that you needed at one time but you don’t need them anymore. It’s a good idea to check your active plugins every once in a while & deactivate the plugins that are no longer being used.

3. Find out which plugin takes more time

How often does it happen that your WordPress website suddenly becomes very slow? In most cases, the reason for this is some plugin which is taking a long time. One way to fix this is deactivate all plugins, then activate each plugin one by one & check if your website is loading normally or not. That can be very time consuming if you have many plugins that are active.

WordPress has a plugin, P3 (Plugin Performance Profiler) that creates a performance report for your site. It measures the impact of each plugin on your site’s loading time. The plugin has about 100,000+ installs. So it is used widely.

Once it’s installed & activated, you can click on the “Scan Now” link below the plugin on the WordPress plugins page. Or you can go to that page from Tools -> P3 Plugin Profiler link. This is what you will see if it’s the first time you are loading that page:

P3 Opening Page
P3 Opening Page

It shows the number of active plugins that your site has. You need to click on “Start Scan” in order for the plugin to start checking all the active plugins & produce a performance report.

When you click on “Start Scan”, a popup like shown below appears. It allows you to choose if you want to run an Auto Scan – where the plugin automatically browses various pages on frontend & on admin, or a Manual Scan – where the admin needs to manually click on various pages & links and accordingly the report will be generated. Give your scan a name & click on “Auto Scan” (or “Manual Scan” based on your preference).

Scan preferences
Scan preferences

Once the scan is over, it shows the below screen indicating that the scan is completed.

Auto-scan complete
Auto-scan complete

Clicking on “View Results” displays the plugin performance report as shown below:

Runtime by Plugin
Runtime by Plugin

It shows that the WooCommerce plugin takes about 50% of the time. Then the WooCommerce Booking & Appointment Plugin takes about 40%. Taking the mouse-over the graph will show the exact percentage & the load time the plugin takes.

Plugin performance details
Plugin performance details

Conclusion

Deactivating unwanted plugins or using compression does result in huge gains. Also identifying the plugins taking a longer time is essential so you can either contact the plugin author about it or use an alternative that has a less impact on your website load time.

LEAVE A REPLY

Please enter your comment!
Please enter your name here