Tips to improve the speed of a WordPress website

Posted January 22nd 2019

Website speed is an important factor for SEO and site traffic. It also said that faster sites do end up ranking higher. Hence people have started focusing more on the page speed. Here is the list of some tools to examine website speed.

All of the tools mentioned above, provide us with an insight of each issue and solutions to each issue on the tested website. you can go through the suggestions provided by the tools mentioned above to increase your site speed.

Serve optimized images

Here some general techniques to increase a WordPress website speed.

Images make people attracted toward your content. However, if images aren’t optimized, they could be damaging rather than supporting. Non-optimized images are one of the most common speed issues that the websites face.

There are some good plugins available in the market which can help you in optimizing the images. here is the list of such plugins:

  • Smush Image Compression and Optimization
  • EWWW Image Optimizer
  • Compress JPEG & PNG images
  • ShortPixel Image Optimizer

Enable Browser Caching

Browser caching temporarily stores visited web page resources on local disk. So, if someone visits the webpage again, the browser requests only updated data from the server & load other data from the cached content. Hence, Enabling Browser Caching became important to load your web pages faster.

Browser caching can be enabled by manually setting the expiration time for various resources into the htaccess file on Apache or by setting cache-control header & expires headers to your server block on Nginx or by using a plugin. Below is the list of some available plugins in the market to enable browser caching:

  • WP Fastest Cache
  • W3 Total Cache
  • Leverage Browser Caching
  • WP Performance Score Booster

Enable gzip compression

GZIP compression means zipping(compressing) pages on a server before the page is sent to the visitor. Enabling compression can significantly reduce the loading time of your page. For enabling GZIP compression you can use listed below plugins :

  • Check and Enable GZIP compression
  • WP Performance Score Booster
  • W3 Total Cache
  • Warning: Many shared hosting servers do not support gzip compression. Below is the list of modules to enable compression on your server.
  • Apache : mod_deflate
  • Nginx : ngx_http_gzip_module

Html, CSS and Javascript Minification

Minification implies eliminating extra spaces, lines and unnecessary characters from the website source code. Minified files are faster to load and enhance your site’s speed.

For Html, CSS and Javascript minification you can rely on plugins like Autoptimize, W3 Total Cache, WP Super Minify or Better WordPress Minify.

Defer javascript parsing/Asynchronously load javascript

To serve a webpage to the visitor, the web browser parses all the tags added on the web page. This parsing adds page loading time. By reducing the amount of javascript required to display the web page or deferring javascript parsing until required, you can reduce the loading time of a web page.

To defer javascript parsing, you can use given below plugins or you can use WordPress filter hook given below to add defer/async to script tags.

  • Async JavaScript
  • Autoptimize
WordPress filter hook:
function add_asyncdefer_attribute($tag, $handle) {
      // if the unique handle/name of the registered script has 'async' in it
      if (strpos($handle, 'async') !== false) {
            // return the tag with the async attribute
            return str_replace( '<script ', '<script async ', $tag );
      }
      // if the unique handle/name of the registered script has 'defer' in it
      else if (strpos($handle, 'defer') !== false) {
            // return the tag with the defer attribute
            return str_replace( '<script ', '<script defer ', $tag );
      }
      // otherwise skip
      else {
                return $tag;
      }
}
add_filter('script_loader_tag', 'add_asyncdefer_attribute', 10, 2);

To use above hook just add ‘async’ or ‘defer’ to your script handler. So, your add_enqueue_script call will look something like below :

wp_enqueue_script( 'scriptname-defer', ……. );
                  OR
wp_enqueue_script( 'scriptname-async', ……. );

The difference between async & defer is explained below:

  • Async downloads the script file during HTML parsing & pause HTML parser to execute the script when it has finished downloading.
  • Defer downloads the script file during HTML parsing & will only execute it after the parser has completed.

Implement the Content Delivery Network (CDN)

CDN cache your website content on geographically distributed server & provide cached content from a web location nearest to a visitor. The primary goal of a CDN is to enhance site performance by reducing the time required to transmit data to site visits.

To implement CDN on a WordPress website, you can choose a web hosting company that offers a CDN as an integrated part of their services or you can rely on the third-party service provider.

If you choose a hosting provider with CDN service, you’ll need to update your account settings to make sure it’s enabled on your website. For third-party integration you need to follow below steps:

  • Choose a CDN provider & get registered
    • Here is the list of some well known CDN providers: MaxCDN, Cloudflare, Rackspace, Akamai, Amazon’s AWS and CoralCDN.Choose a CDN provider & get registered
  • Choose a plugin to implement CDN on your website.
    • There are two powerful plugins which can help you to implement CDN on your website: WP Super Cache & WP Total Cache
  • Connect Chosen CDN to your WordPress setup.
    • The last step is to set up your WordPress site to actually call the CDN instead of the server files. This is the step where you’ll configure the plugin you chose in the previous step.

Optimize WordPress Database

WordPress database collects a lot of additional data such as revisions, data from plugins you are no longer using, unused tags, spam or trashed comments, and more. Removing this additional data can significantly decrease your database size which speeds up your backup process and can add minor performance gains as well.

Below are the plugins which you can use to optimize your WordPress database.

  • WP-Optimize
  • WP-Sweep
Ankita Tanti

Ankita Tanti

Sr. WordPress Developer

Team leader for Wordpress & CMS technologies at Creole Studios, and a die-hard believer in the power of open source technologies.