Improve WordPress site PageSpeed in Simple Steps

Site PageSpeed is one of the important factors for better traffic not only for SEO but for a better user engagement experience. Use the following quick and simple steps to improve WordPress site PageSpeed.

Working on using the right keywords is also important. Today, quality is most important than anything else. However, filling the gaps as much as possible to make your blog perfect will always help. Quality content can be built with using the right keywords that people are generally using to search information or which comes handy to them.

Install a Caching Plugin

The plugin W3 Total Cache caches and compresses files to reduce page download time. I have seen great improvements in the page load time in the Google’s PageSpeed Tool.

Modify your site’s .htaccess File

Login to your site’s file manager and edit .htaccess file (backup the file first!). Then copy the below code and paste in the top of the .htaccess file. This is to improve on Leverage Browser Caching PageSpeed factor.

##### EXPIRE CACHING - LEVERAGE BROWSER CACHING #####

# Enable expirations
ExpiresActive On

# Set default expire time
ExpiresDefault “access 2 week”

# Specify expire time by file type
ExpiresByType image/jpg “access 1 month”
ExpiresByType image/jpeg “access 1 month”
ExpiresByType image/gif “access 1 month”
ExpiresByType image/png “access 1 month”
ExpiresByType text/css “access 1 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType text/x-javascript “access 1 month”
ExpiresByType image/x-icon “access 1 month”

## END EXPIRE CACHING ##

Use Asynchronous Code for AdSense

I use WP Insert for inserting ads on the pages, it helps me manage the ads easily from time to time. Ensure that you are using Asynchronous AdSense Code.

To get the Asynchronous AdSense Code, goto your Google AdSense Account, My Ads then click on Get Code for the Ad of your choice. In the overlay popup, click the dropdown and select Asynchronous as shown below. Currently they are in BETA phase, but it works well on my website. Copy this code and paste it either in WP Insert or whatever plugin you use for AdSense or directly on the page as per your convenience.

asynchronous adsense configuration

Use Asynchronous Code for Social Plugins

Social plugins add a lot of overhead of Javascript and CSS contributing in more load time of the pages. Using asynchronous plugin like Async Social Sharing may help you reduce the overall load time of the page of your WordPress site.

To improve the PageSpeed for the factor Eliminate render-blocking JavaScript and CSS in above-the-fold content, you will need to ensure that the Javascript and CSS are not blocking the page load meaning the rendering of the page is not blocked while these asset files are loading. The solution to this is to move the JS and CSS files towards the footer of the page so that they load after above-the-fold content is loaded. Above-the-fold content means the content that is present in the viewport (which is not below the visible screen). I have added Footer Javascript Plugin for the same.

Compress Image with Smush.It Plugin

The images can be compressed without losing (visible) quality using the plugin like Smush.It. To smush already uploaded images, Go to Media >> Bulk Smush.it. It takes couple of mins depending upon number of images your site has in the media library but it compresses the images contributing in better PageSpeed.

Lazy Loading of Images

Lazy loading of images can significantly improve in user experience. It loads the images as they appear in the viewport. This means that the images which are not visible in the current screen are downloaded when the user scrolls down to that area of your page. You may use JQuery Image Lazy Load Plugin for this.

Minify CSS / JS

If you have any custom CSS or JS of your own, you can first minify using online tools then upload it to your WordPress site.

That’s all! Now check your site’s PageSpeed Insights and let me know if you got any improvement.

Interesting Links

Why Prefer Subdirectory WordPress Multisite

I use to get a lot of (at least) impressions for a keyword television on this blog. So I decided that I would rather make subdomains for this category and I created WordPress multisite with multiple subdomains including tv.tipscow.com, etc. With this setup, however, the impressions came down so there was no way for me to improve the conversion rate but changing from subdomains to subdirectory WordPress Multisite seems to be working!

Also, while building the backlinks, i realized that subdomains were not being given much importance and only the main domain’s backlinks were working for the organic search.

So, I changed the URL structure from subdomains to subdirectory of this WordPress Multisite. Now, I don’t have to worry about backlinking different domains. Alone, tipscow.com would help me build the rapport. I wrote the article steps for changing Multisite WordPress blog from subdomains to subdirectory.

I would be glad to discuss if you have any other point of views.

Steps to change WordPress Multisite from Subdomain to Subdirectory

I decided to change the multisite’s URL structure from subdomain.domain.com/ to domain.com/subdomain/ because of the reason I explained in Why prefer multisite with subdirectory url structure over subdomains post for WordPress Multisite.

I searched over internet and what I found on internet was very close to what I was trying. So I am writing this post to list out step by step what precisely worked for my site while changing the multisite WordPress from subdomain to subdirectory structure.

Steps: WordPress Multisite from Subdomain to Subdirectory

  1. Before doing any changes, do take a backup described on the official WordPress site: Backup WordPress Database
  2. Now, take backup of the files you are going to modify e.g. .htaccess
  3. Now, open your .htaccess file from the root directory of your WordPress install and replace the code between “# BEGIN WordPress” & “# END WordPress”. There are instructions for updating code based on your WordPress version but it was really very confusing for me. So I tried different options and the code below worked for me.

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    # END WordPress

  4. Ensure that you set redirects at subdomains level to not lose on any traffic. Use the following code to setup the redirects just above “# BEGIN WordPress” that you updated in the previous step. I have copied the exact code from my wp-config for your understanding. Note that tipscow.com is the main domain and subdomains are tv, fashion, storage, mobile, mechanical & travelogue. Use the exact code below and only change your domain and subdomain names. The back slashes and quotes are important and that what made it work.


    # Subdomains
    RewriteCond %{HTTP_HOST} ^tv.tipscow.com$
    RewriteRule ^(.*)$ "http\:\/\/tipscow\.com\/tv\/$1" [R=301,L]

    RewriteCond %{HTTP_HOST} ^fashion.tipscow.com$
    RewriteRule ^(.*)$ "http\:\/\/tipscow\.com\/fashion\/$1" [R=301,L]

    RewriteCond %{HTTP_HOST} ^storage.tipscow.com$
    RewriteRule ^(.*)$ "http\:\/\/tipscow\.com\/storage\/$1" [R=301,L]

    RewriteCond %{HTTP_HOST} ^mobile.tipscow.com$
    RewriteRule ^(.*)$ "http\:\/\/tipscow\.com\/mobile\/$1" [R=301,L]

    RewriteCond %{HTTP_HOST} ^mechanical.tipscow.com$
    RewriteRule ^(.*)$ "http\:\/\/tipscow\.com\/mechanical\/$1" [R=301,L]

    RewriteCond %{HTTP_HOST} ^travelogue.tipscow.com$
    RewriteRule ^(.*)$ "http\:\/\/tipscow\.com\/travelogue\/$1" [R=301,L]

  5. If there are not many subsites, you can simply goto http://yourdomain.com/wp-admin/network/sites.php and edit the paths from “/” to particular “subdomains”.
    change subsites structure from subdomain to subdirectory

  6. If you have many subsites, you can update them using phpMyAdmin from your cPanel.

If you run into any issues, restore the backup and try again. If there are still any problems, discuss them here and I would be glad to help you.

[Resolved] Not a valid feed template – WordPress Error

So, I opened up my webmaster tools to find out that some pages were giving 404 error. The error was showing like this: “ERROR: sort is not a valid feed template.”. I banged head for an hour on this before I actually fixed the issue.

Wherever there was a keyword XML in my URL, it gave this error. For example, for the url, http://tipscow.com/how-to-include-xsl-in-xml/ showed the error: ERROR: how-to-include-xsl-in is not a valid feed template. Note that xml keyword is not mentioned in the error. So anything before XML is included in the error.

Another URL giving me problem was: http://tipscow.com/sort-xml-attribute-using-xslt/. For this as you can guess the error said: ERROR: sort is not a valid feed template.. So clearly anything before xml was in the error. I am still figuring out what caused this problem.

Solution for Not a valid feed template

Options like putting dataxml or xmlfile will also not work. The reason is that it has xml again. So, I finally settled the issue with updating the post URL to http://tipscow.com/include-xsl-in-x-ml/ (The thing that helps is “xml” keyword not in the URL.

For the other URL, it was fixed with: http://tipscow.com/sort-x-ml-attribute-using-xslt/

Don’t forget to

When you finally sort the error and fix it (especially if a URL change is involved, don’t forget to set a redirect to the correct URL from the old URL. Otherwise you might just loose the traffic. I use simple 301 redirects plugin it is very very simple and easy to use.

Fix for Fatal Error Maximum execution time 30 seconds exceeded WordPress

Quick Fix of the PHP Fatal error Maximum execution time 30 seconds exceeded in WordPress. There are three ways. Use either one. Also please backup the files before making changes so that you can revert the same if there are any issues.

Fixing “Maximum execution time 30 seconds exceeded

1. Wp-config.php

set_time_limit(60);

Add this line above “/* That’s all, stop editing! Happy blogging. */” comment.

OR
2. htaccess

php_value max_execution_time 60

OR
3. php.ini

max_execution_time = 30 ;