• Quick Tips for Beginner

To speed up your blog:-

You should implement following easy techniques.

  1. Very first - Host your blog at fastest web hosting
    I can assure you, this investment will be totally worth for you. I'm using Cloudways at this blog for faster response time. You can feel it speed.

  2. Use Content Delivery Network
  3. Use Cloudflare or MaxCDN for improving your blog performance.

  4. Always use compressed and resized images
  5. I use Adobe Photoshop for resizing and for compressing image.

  6. Minimize HTTP Request by combining CSS & JS in head
  7. You can use Autoptimize Plugin to handle this job efficiently.

  8. Use less Plugins
  9. This can significantly improve your WordPress website speed in no time.

  10. Setup proper cache
  11. You must set this for serving content faster and saving bandwidth.

  12. Enable gZIP compression
  13. GZIP is the key of success. It help you to serve file in compressed form. Remember WinRar? Similar thing, this technique do for your browser

    I hope this help. For more better performance, please keep reading below my advanced guide. If you need any urgent help, please write at admin@gulshankumar.net


WordPress Speed Optimization is essential for SEO and great user experience. You will learn here about optimizing WordPress Theme (Agent Side), Web Hosting Server (Server Side Optimization) and Plugins installation respectively. Okay! So let’s start learning on optimizing these three main components of WordPress. Here all tips are related to each other, for better understanding you are requested to read and implement very carefully. Please take backup before continue.
wordpress speed optimization

Please check your website at GTmetrix to find out the root cause of slowness. Look carefully at their recommendation and start applying step by step as I have mentioned below.

How to get started?

1. Take Full Backups (including .htaccess & wp-config.php)
2. Login to GTmetrix.com and run speed test.
3. Keep Installed and Activate ‘Code Snippet‘ Plugin (For adding PHP code)
4. You must have FTP Details (For adding some .htaccess code)
5. Choose Cloudways Hosting with your target traffic location.
6. Notepad++ (Application)
7. Google Chrome / Firefox. (For real testing of network timeline)
8. Optimus Plugin (For bulk images optimization)

Jump to

Optimize WordPress Theme

I have worked on many themes of WordPress and I finally realized that all theme require speed optimization. No any WordPress themes come with already-optimized. You can optimize WordPress theme by applying these all important tips.

1Analyze and Remove Unused CSS

This is how using Google Chrome, you can check unused CSS by page by page.

CSS should be small in size as possible as. I guess, you are not using 100% CSS. Therefore, you can analyze some unusual CSS using Google Chrome browser. Open your website in Google Chrome, Then Press F12, and Click on Audits, Click Web Page Performance check-box and Audit Present State radio button and Click Run. You will see all unused CSS rules.Later you can remove all unwanted CSS manually.

Please note: Remove only if you know what you are going to remove for other web page also.

Want quick? why not use this online tool. Recently, I found it and I tested for this blog. It worked great for me. I’m very impressed with this tool. Unexpectedly, first time using this tool I optimized Font Awesome CSS in very less time.
Alternative Manual way:
In WordPress Dashboard, go to Appearance > Editor, now look at Table of Contents in CSS file. Note down what you are not using, and simply remove it. In my case, I removed Calender’s Widget CSS which I was not using nor I had planned to use in far future.

2Remove WordPress Query String

Check your WordPress website source code, you will see many unnecessary query string like this….


added in CSS and JS files URL. It is the main cause of delay in rendering static resources due to unusual redirects from query string version to non-query string version. Also, with query string browser become unable to store in cache memory.

Query String

You can remove all unwanted query string of your WordPress blog by adding this code in your Functions.php file of your current theme.

// Remove Query String
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 );

Sometime these query string are also being attached with external web fonts. Chances are that’s you have to remove manually by editing functions.php of current theme or editing those plugins files which are using those web-fonts.

3Minify CSS, JavaScript and HTML

It is very difficult to minify all CSS and JavaScript manually. So, you should take advantage of a useful plugin called Autoptimize to do this job more efficiently. I like this plugin so much because, it does multiple works for me. First it minifies CSS, JS, HTML elements and turning small background images into base64URI. Hence, it dramatically reduces many DNS lookup by combining all CSS and JS file into a single separate URL. Minifying website resources is very important to render web pages quickly. You should never ignore this because CSS and JS are main blocking resources by default.

Caution: After minifying HTML, make sure to check your site design properly. In my case, my list items at post meta went too close. I fixed it by adding padding of 2px.

4Prefer loading JavaScript with async and defer tag

You should load all external and less priority JavaScript with async and defer tag. It will eliminate the render blocking issue.

function add_async_defer_attribute($tag, $handle) {
    if ( 'my-js-handle' !== $handle )
        return $tag;
    return str_replace( ' src', ' async defer src', $tag );
add_filter('script_loader_tag', 'add_async_defer_attribute', 10, 2);

Caution: Don’t implement this technique for jQuery.

5Remove Unusual PHP Execution in WordPress

Many folks suggest that to reduce PHP execution, you should replace some PHP code of header and footer with simple HTML code. You can find such code above <?php wp_head(); ?> hook in your theme header.

<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />

Tips: You can easily get already html formatted code through your website source code. To open website Source code, Please go to this address

view-source:yourdomain.com or Press CTRL+U buttons in Windows.

Keep in mind that you should replace only that PHP code which is not going to be changed forever in your WordPress theme. On same principle you can remove some unnecessary PHP code through your footer of your WordPress theme. You can find such code above <?php wp_footer(); ?> hook.To have little PHP execution, delete all inactive Themes & Plugin. Whenever your site is being in development mode; I recommend only that time keep one latest version of a WordPress default theme. Suppose, In case if your choice theme gets broken, then it will be able to revert automatically to the Default theme.

6Choose Great Theme framework

A perfect theme framework can help to render pages quickly. I like that theme which use Latest version of technology such as HTML5, CSS3. Take advantage of Include tag in HTML 5, Hence in this way you can reduce the amount of HTML output.You may like to Read: How to choose Perfect WordPress Theme

7Avoid CSS import

If your WordPress theme using imports method to load CSS, then it obvious your style sheet will not load quickly in the old browser such as Internet Explorer (Previous to IE9).

8Don’t use default WordPress Emojis

First they load this inline JavaScript, which cause delay in rendering.

<script type="text/javascript">
			window._wpemojiSettings = {"baseUrl":"https://s.w.org/images/core/emoji/72x72/","ext":".png","source":{"concatemoji":"http://matthewhorne.me/wp-includes/js/wp-emoji-release.min.js"}};
			!function(a,b,c){function d(a){var c,d,e,f=b.createElement("canvas"),g=f.getContext&&f.getContext("2d"),h=String.fromCharCode;if(!g||!g.fillText)return!1;switch(g.textBaseline="top",g.font="600 32px Arial",a){case"flag":return g.fillText(h(55356,56806,55356,56826),0,0),f.toDataURL().length>3e3;case"diversity":return g.fillText(h(55356,57221),0,0),c=g.getImageData(16,16,1,1).data,d=c[0]+","+c[1]+","+c[2]+","+c[3],g.fillText(h(55356,57221,55356,57343),0,0),c=g.getImageData(16,16,1,1).data,e=c[0]+","+c[1]+","+c[2]+","+c[3],d!==e;case"simple":return g.fillText(h(55357,56835),0,0),0!==g.getImageData(16,16,1,1).data[0];case"unicode8":return g.fillText(h(55356,57135),0,0),0!==g.getImageData(16,16,1,1).data[0]}return!1}function e(a){var c=b.createElement("script");c.src=a,c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g,h,i;for(i=Array("simple","flag","unicode8","diversity"),c.supports={everything:!0,everythingExceptFlag:!0},h=0;h<i.length;h++)c.supports[i[h]]=d(i[h]),c.supports.everything=c.supports.everything&&c.supports[i[h]],"flag"!==i[h]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[i[h]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings);

Second, they fetch it and then finally they serve it through browser without any proper cache. So, it is better to use Classic Smiley plugin. It will elimiate the above JavaScript will load on demand with proper cache.

9Inline Small CSS and JavaScript

If you will load tiny CSS too many times by calling HTTP, it will just slow down your website due to tons of extra DNS lookup. I can remember that a popular spam comment fighter plugin of WordPress, Akismet load a small CSS file from the footer. Since, our aim is to reduce DNS lookup and serv pages quickly to our visitor, thus It would be nice to inline such files. Alternately, easy solution is Autoptimize plugin, which can automatically combine your whole CSS of your WordPress theme in a single separate file. From the next time, never you have to worry about serving CSS in your WordPress blog.

10Combine small images into CSS sprite

Did you know? Your theme might load very small images by calling HTTP and for this very reason your site may be very slow. Might those images will be in use by your current theme as background images/slider; navigation symbol; social media link images; etc.There are main two advantages of converting small images into CSS Sprite. At first it will reduce DNS lookup second it can be cached for a time-period. Now a day, Internet Giant Google are using this technology. You can also generate your CSS Sprite via online tool via Spriteme. Incase if you are not able to generate CSS sprite for your WordPress theme, alternatively reduce DNS lookup by generating base64 of small images. Keep in mind that base64URI couldn’t be cached by web browser.

11Optimize Theme Background Images

If you are using background images in your WordPress Blog, you should load in this ways.
Use small images in tiles format with CSS Sprite, base64URI or remove it completely to save bandwidth.
If you are using large images then first compress it and serve that file from a static domain or sub-domain. Also, make sure your background images should have long expiration period.

12Add the missing favicon and touch icons

And, here is a Important Tips for every Self Hosted WordPress user by great Indian web geek – Amit Agarwal (labnol.org) – “Your WordPress theme may not even include references to the favicon (favicon.ico) or the Apple touch icons but web browsers and feed readers may still request them from your server. It’s always better to serve a file than returning a 404.”

Put a 16×16 favicon.ico and a 144×144 apple-touch.png file in the home directory of your blog. Then add this line to your .htaccess to redirect all apple touch icon requests to that particular file.

Yahoo Developers recommends – Your 16×16 pixels .ico format favicon size should be less than 1 KB. Thus, it will be cached in web browser.

RedirectMatch 301 /apple-touch-icon(.*)?.png http://example.com/apple-touch.png

Alternative Method
Hint: To quickly generate multiple size favicons in one click, you can use this Favicon Generator Tool. I’m very happy to recommend this awesome tool.

13Understand how Responsive theme can slow down your website

I’m not against Responsive theme, because it’s easy managing a single website for all platforms. But I may contradict with a truth that responsive themes are heavy because they load some extra CSS and JS resources as comparison to a non-responsive theme. Here is a simplest solution to get rid of this problem.
Serve Dynamic Resources according to the USER Agent (device platform). There are many theme changer plugin available from which you can manage one non-responsive or fast loading theme for desktop and another a mobile friendly and responsive theme for small devices.
Prefer loading each Style sheet CSS according to the Screen Size parameter.

14Convert normal JS to Eval 64

Wants to highly compress your JavaScript? Do you know, You can compress JavaScript up to 20% more using Eval 64 convertor method as comparison to normal JavaScript compression. It is little bit hard you have to compress manually. Be aware, that some JS may not work properly. Implement this method at your own risk.
Recommended plugin: JS & CSS Script Optimizer
Caution- Add jquery.js in exclusion list, else some feature may not work.

15Don’t use Flash object in your Theme

Some people still prefer Flash theme or flash object in logo even while it is not being SEO-friendly and mobile-friendly. According to Google Developer Rules,You should never use such type of theme, because it generally loads slowly, main causes of hang and crashes. Hence, it is not considered as mobile friendly object.

16Specify Meta Character Tag

gTmetrix recommends that Your WordPress theme may not Specified Meta Character tag which can be helpful for browser to understand the elements of your website. Add this META tag in your theme header.

 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Or, you can simply add Meta Charset through server side. Open .htaccess file and just add one line. I recommend this method; you don’t have worried later even if you change your WordPress theme.

#Default Charset
AddDefaultCharset utf-8

17Use Special Stylesheet for old Browser – Internet Explorer

To make your theme cross-browser supported, it is highly recommend adding separate style sheet, html class, and html5.js for older IE versions. [Previous to IE9]

18Prefer Async load of JavaScript

Use Async method for loading heavy or less important JS to avoid seeing white page for a long duration while loading WordPress website. You can do this with a plugin called Async JS and CSS. I do not recommend this technique for loading CSS in async mode.

19Put CSS in the top of the document

To show your colorful website quickly, you should serve high pririoty thing – header CSS. So, it recommends loading it firstly than before anything. It is little bit technical, if you are advance user then only you can do this via Selective Plugin load plugin. Set your CSS delivery plugin to execute first.

20Optimize the Order of CSS Stylesheet and JavaScript.

However, you should try to load your CSS first, then after JavaScript. Autoptimize plugin automatically do this Job automatically. Since, it loads all CSS in one URL, then after it load all JS in one URL.

21Compress Images

A compressed image can load much faster than a normal image. You can optimize images by using Adobe Photoshop software. Open with, go to file menu and click Save for web and Devices. That’s it. Or, you can also do via plugin called ShortPixel or you can also compress your images online. There are many online tools for compressing images available on Internet. As you prefer, I personally use Photoshop.

22Serve scaled images

Never scale down large images into small images by defining width and height parameter in html tag. At least, kindly serve scaled images on the size which you really need to display. Have you thought, if you are serving 1 MB size (1024×768) images just in resizing with html by 650×300? It doesn’t make any sense. In this way you can only suck other time and your own precious bandwidth too.
Thus, It is recommended that if your need 400×250 size images first scale yourself using any Photo Editor, compress it, then add with true height and width parameter. So, browser will able to understand the size, and it will get less size images.

23 Your WordPress theme should have correct DocType

Mobile Badge in Google SERPs. It indicates that my WordPress theme is mobile-friendly.

Incorrect declaring DocType may lead to Mobile SEO penalties, as well as it will render your web pages in different style (In IE). Hence, it affects page speed. For instance, if you want to declare your website as mobile friendly then you must add this line above <head>, you will notice that you will get mobile badge in Google Search very early.

 <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" prefix="og: http://ogp.me/ns#">

24Avoid CSS Expression

For performance reason, it is not good idea to use CSS expression every time when you start writing an HTML code. In other words, you should not use CSS code in the HTML body tag. Whatever you need style please mention in your stylesheet.

25Remove Duplicate CSS & JavaScript

Consider checking your CSS, JavaScript before publishing it online. I don’t think it is necessary to repeat five versions of jQuery scripts in a single HTML document. It worthless and only it will increase extra DNS lookup from your site.

264 Reasons you should use latest Version jQuery Script from Google CDN

1. Your theme may reference to local outdated jQuery script, so it is better to change it to latest one
2. I think, jQuery with CDN link will load faster globally
3. Many site uses jQuery from Google Library, so your visitor is going to get benifit of Cached versio too
4. Save your  own bandwidth, let’s don’t put all eggs in one basket 😀

// Load CDN jQuery 
add_action( 'wp_enqueue_scripts', 'register_jquery' );
function register_jquery() {
    if (!is_admin() && $GLOBALS['pagenow'] != 'wp-login.php') {
        // comment out the next two lines to load the local copy of jQuery
        wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js', false, '2.2.2');
// end

Add this above code in your Theme function.

27Remove useless  jQuery-Migrate script from header

WordPress by default include jQuery-migrate in header, concerning incompbaility issue with some plugin. The fact is – If you will latest version jQuery and all plugins then there is no use of jQuery Migrate script.
If you want to remove, add below code in your functions.php

// Remove migrate script

add_filter( 'wp_default_scripts', 'remove_jquery_migrate' );

function remove_jquery_migrate( &$scripts)




$scripts->remove( 'jquery');

$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' );



28Use Mobile-friendly theme on WordPress

You should not block your website static resources such as CSS, JS or any images which is included on your web page. Make a little gap between two links. Your content should not fall outside the viewport. Add this Meta Viewport in your Meta Tag, you can find in header.php file of your current theme.

<meta name="viewport" content="width=device-width" />

Hint – Also, add correct DocType in the beginning of HTML Document or header of your WordPress theme

29Put less required JavaScript in the footer

Just think yourself my dear, how do you will be feel when you will see blank page for a long duration while each loading. So, move all less important JS to the footer which is currently placed in your header of your WordPress theme. I hope this trick will reduce bounce rate as well it will give positive message to your visitors-mind. For example, Use a single JavaScript tracking code. Please don’t use such annoying widget, plugins which are not directly beneficial for your visitors in anyway.

30Minify HTML output of your WordPress theme

For somebody, it may be about keeping HTML tag anonymous. But for me, it important because maintaining the ration between HTML and Content size is a good practice for SEO. Thus it also reduces the size of HTML output hence, helps to speed up WordPress website. To do this you need to simply add this PHP code in your functions.php file of your current theme.


function sanitize_output($buffer) {

    $search = array(
        '/>[^S ]+/s',  // strip whitespaces after tags, except space
        '/[^S ]+</s',  // strip whitespaces before tags, except space
        '/(s)+/s'       // shorten multiple whitespace sequences

    $replace = array(

    $buffer = preg_replace($search, $replace, $buffer);

    return $buffer;



Denial: This minifcation code may not support on all theme.

So, above you were reading about optimizing WordPress theme with various techniques.

Optimizing Server

In this 2nd part, now I would like discuss about Optimizing Server. No doubt, your web hosting server is the powerhouse of WordPress website. No matter how much you have done optimization, if your server will slow, you can’t aspect to load your website under 1-2 sec.

Do you know? The leading Social Networking Website – Facebook has not implemented many on-page optimization techniques to speed up. But then also it load under 1.5 sec. You might be wondering how? To make your site blazing fast, you must learn following important tweak about Web Server.

Before telling you anything, I would like to declare that first of all disable Cache plugin to avoid conflict. Else, you may get server side Error 500.

The very first thing
You have to understand that Hosting matters a lot for all over performance. Since, your web server has to be very fast so you have to think less about tweaking it, optimizing it in many ways. If you are looking for choosing best Web Hosting Company for WordPress Hosting, I recommend using country based NGINX web server hosting. It will reduce the latency between multiples connections. Prefer those web hosting which support HTTP2.0 with ALPN. BTW, If you are looking for best hosting at cheapest price, you can go with Creative Soch. It has affordable plan which is best for new WordPress user.

31Use cookies-Free domain to serve Static resources

80-90% of the end-user response time is spent downloading all the components in the web page: images, CSS, scripts, objects, etc. As such, serving the static content from the cookies-less domain is a good practice for all websites, where even a little extra time to load something can mean long lag times. WordPress happens to have a provision to enable this feature.

32Take advantage of CDN

CDN is a great way to serve static content speedily, I suggest leave your web host to process only normal PHP Execution and move all static contents (except HTML) to a CDN. It allows not only parallel downloading but also serve website content from nearest server. Do you know? Why Google, Facebook is loading fast from everywhere? Think about it. Choosing a CDN can be great impact on your Website speed. If you small business then I recommend Max CDN. If you have large business then you should use Akamai CDN. It comes at reasonable price.

33Use Dedicated IP Address

This is my personal research in which I found that those all website who were using Dedicated IP address, there connection time and server response time was Less than 200ms. Google Page Insight Tool also recommend for same time period. That website that was not using Dedicated IP address, I found there website was taking a long time for serving first byte. Dedicated IP improve speed as well as it is also beneficial for SEO to maintain authenticity of website. Also, you should Redirect Dedicated IP address to your main domain to avoid duplicate content issue.

34Enable gZIP Compression for Static Contents

Let me tell you first, what is gZIP? If you will enable gZIP compression your 1 MB size of website will be serve in compressed form at approx. 600 KB. So, this is how you saved so much precious bandwidth. Hence, in this way you can easily improve your website loading time will be improved easily. It is supported in limited Server. After adding this below code, you will see amazing improvement in loading time. Cache plugin automatically do this, so If you already using then first disable it before implementing.

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4.0[678] no-gzip
  BrowserMatch bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent

35Avoid Empty SRC, 404 URL

Don’t take it lightly. Every time browser land at empty SRC or broken URL, then some browse handle it efficiently, but old browser take a special long time to generate a new window of 404. Hence, it affects your loading time. To avoid this problem, keep in mind these 5 common things to avoid this problem.

Don’t forget to add http:// or https:// while creating hyperlink to the external pages.

While hyperlinking, never leave target URL at www or non-www.

Don’t serve any content from untrusted domain or other resources.

Don’t forget to add device-specific site icons.

After completing a creation of new web page, check with GTmetrix.

You may check your all 404 links via Broken Link Checker plugin or using this online tool or also you should check once at Web Server Log file.

36Disable Hotlinking

You can’t monitor easily who is stealing your server bandwidth, and slowing down your website. So, you can simply disable hotlinking through your Hosting Panel. If you are using Cloudflare, under Scrape Shield menu there is also option to do. Or, you can simply add this code in the .htaccess

# Hot link Protection
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?gulshankumar.net [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bing.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?ask.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?twitter.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?facebook.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?pinterest.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?plus.google.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]

Ps. Please replace my domain (gulshankumar.net) with your own to keep whitelisted. Have custom requirement? Create own syle at http://www.htaccesstools.com/hotlink-protection/

37Setup leverage browsing cache

Sometime, it is also known as defining Expiry header. This will enable cache to your static resources. Thus, it will be serve website non-changeable content to returning visitors quickly.
Basic Tips: To protect from conflict, if you are already using any cache plugin, then you have to first disable it before implementing.

# Leverage Browser Caching by setting HTTP header expires
<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault "access plus 600 seconds"

  # CSS
    ExpiresByType text/css "access plus 1 month"

  # Data interchange
    ExpiresByType application/json "access plus 0 seconds"
    ExpiresByType application/ld+json "access plus 0 seconds"
    ExpiresByType application/vnd.geo+json "access plus 0 seconds"
    ExpiresByType application/xml "access plus 0 seconds"
    ExpiresByType text/xml "access plus 0 seconds"

  # Favicon (cannot be renamed!) and cursor images
    ExpiresByType image/x-icon "access plus 1 year"

  # HTML components (HTCs)
    ExpiresByType text/x-component "access plus 1 week"

  # HTML
    ExpiresByType text/html "access plus 0 seconds"

  # JavaScript
    ExpiresByType application/javascript "access plus 1 month"

  # Manifest files
    ExpiresByType application/manifest+json "access plus 1 year"
    ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"

    ExpiresByType text/cache-manifest "access plus 0 seconds"

  # Media
    ExpiresByType audio/ogg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png  "access plus 1 month"
    ExpiresByType video/mp4 "access plus 1 month"
    ExpiresByType video/ogg "access plus 1 month"
    ExpiresByType video/webm "access plus 1 month"

  # Web feeds
    ExpiresByType application/atom+xml "access plus 1 hour"
    ExpiresByType application/rss+xml "access plus 1 hour"

  # Web fonts
    ExpiresByType application/font-woff "access plus 1 year"
    ExpiresByType application/font-woff2 "access plus 1 year"
    ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
    ExpiresByType application/x-font-ttf "access plus 1 year"
    ExpiresByType font/opentype "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"

38Setup Cache Control Header

You can setup cache control header for web browser to handle cache. Add this code in your WordPress .htaccess

# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
    <filesMatch ".(ico|jpe?g|png|gif|swf)$">
        Header set Cache-Control "public"
    <filesMatch ".(css)$">
        Header set Cache-Control "public"
    <filesMatch ".(js)$">
        Header set Cache-Control "private"
    <filesMatch ".(x?html?|php)$">
        Header set Cache-Control "private, must-revalidate"
# END Cache-Control Headers

39 Reduce DNS lookup, Monitor Request Size

The more resource you will be call from http or https, the more your website will be goes to slow down. So, try to keep request amount minimum. Every time a web browser visit new web address to lookup, it’s take few long time to get response from web server. Browser has limits to process the number of DNS lookup in one time. Check your website at gTetrix, Go to Timeline tab, I suggest remove those resources which takes longer time to responds and serve.

40Is SSL really slow down a website?

The answer is NO. It is truth that HTTPS connections need some extra time to handshake check browser integrity. So, nothing as you imagines. If your answer is yes, I want to ask you very politely – How many time you seen Google, Facebook, Twitter is slow? They all are using SSL. Infact, I have also started using.

41Disable Pingback and Trackbacks

If you have busy WordPress site, then it’s good idea to reduce some amount server load by disabling pingbacks and trackbacks.

wordpress pingbacks trackbacks

Uncheck pingback and trackback checkbox in Discussion settings.

42Serve images only on Page Scroll down

Especially if you want to load your blog speedily, load your images after content. In this way, you can save your website bandwidth by installing jQuery Image Lazy Load WP.

43Optimize WordPress Database

Heavy Database can slow down your website. Well, by optimizing WordPress Database, you can delete all old post revisions, plugins transitions, etc.
Recommends plugins for Optimizing Database is: WP Sweep. Your MySQL Database should be small as possible as. You can do some important things to reduce database size.
Turn off post revision
Open Wp-config.php > add this line

define( 'WP_POST_REVISIONS', false);

Alternatively, you can also set limit for Post Revision

define( 'WP_POST_REVISIONS', 3);

Source: Editing_wp-config.php

44Change Auto Save Post Interval

WordPress has habit to save automatically new post while editing. You can manage time duration by adding this code in your wp-config.php

define( 'AUTOSAVE_INTERVAL', 120 );

45Reduce Server Load using FeedBurner for RSS

Since, our aim is to reduce server load, use Google Feed burner instead of Default RSS Feeds. Add this code in your .htaccess file. Make sure, you replace with your RSS Feed URL.

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]
 RewriteRule ^feed/?.*$ http://www.example.com/feed [L,NC,R=301]

46Block SPAM Bot Traffics and Unwanted Crawlers

Beware of SPAM bot. To prevent your website from spam bot Traffic, you can apply few settings in your WordPress htaccess and the robots.txt file. For instance, you can monitor your traffic-referral using Google Analytics.

# Block Spam Site
SetEnvIfNoCase Via evil-spam-proxy spammer=yes
SetEnvIfNoCase Referer evil-spam-domain.com spammer=yes
SetEnvIfNoCase Referer evil-spam-keyword spammer=yes
SetEnvIfNoCase Via pinappleproxy spammer=yes
SetEnvIfNoCase Referer semalt.com spammer=yes
SetEnvIfNoCase Referer kambasoft.com spammer=yes
SetEnvIfNoCase Referer savetubevideo.com spammer=yes
SetEnvIfNoCase Referer buttons-for-website.com spammer=yes
SetEnvIfNoCase Referer poker spammer=yes
Order allow,deny
Allow from all
Deny from env=spammer
# end code

Recommended Plugin: Bot Block

There are some unusual crawler bot who enough to sucks website bandwidth and dilute SEO too. Therefore, add this code per line in your WordPress Website robots.txt

User-agent: OmniExplorer_Bot
Disallow: /
User-agent: FreeFind
Disallow: /
User-agent: BecomeBot
Disallow: /

You can get a complete list at my robots.txt file.

47Reduce Crawl rate to Maintain Server Load

It is only for Popular or busy website, you can set crawl rate to maintain the load on the server. Please note: It can cause few seconds delay in indexing new contents. If you want to do, add following lines in your robots.txt

Crawl-Delay: 10

(Note: Generally, it is not recommended unless if you are using a poor host.)

48Improve Website Speed by Installing PageSpeed on Server

PageSpeed Module can automatically minify your entire WordPress site from server side. Then it will be automatically turn on. If you are using already any Cache plugin or doing all things manually, then you don’t need. You can simply turn it off, thus add this code in your .htaccess file.

ModPagespeed off

If you are getting Error 500 after adding this, it means you web host has not installed this Extensions. Then you can remove ModPageSpeed from htaccess. If you are on Shared hosting, you can contact hosting provider to install this extension.
This is alternative way for on-page optimization. Basically, it minifies CSS and JS. If you managing in other way. You don’t need to worry for this.

49Remove eTag

It is used for caching purpose, but if you have set a expire headers for the static contents then you should disable the eTags functionality. This is how you can disable the eTag using .htaccess file.
Just you need to place one line in your .htaccess file to disable the eTag.

FileETag none

(Only for static nature website. I strictly don’t recommend this technique for dynamic website like blog)
Also read: How to Serve Images Faster in WorPress using WebP Format?

50Specify Very-Accept Encoding

In this way you can enable very accept encoding for JavaScript, CSS, etc. Add this following lines in your WordPress .htaccess file.

# Specify a Vary: Accept-Encoding header

<IfModule mod_headers.c>

<FilesMatch ".(js|css|xml|gz)$">

Header append Vary: Accept-Encoding



51Avoid Unusual Redirects

Redirection takes an extra time to lookup one domain to another domain, so you should keep redirect level minimum. If you are using Facebook like Box, it commons problem they redirect to their landing page. This is a Facebook problem; you can’t do anything for such landing redirects which is not in your hand. But here thing I’m talking about something different that you should stick with one version of URL. Sometime careless changes through .htaccess may lead to non-www to www redirect or vice versa. In that case, you have to define home URL, and site URL in the WordPress Wp-config.php file.


Incase if your WordPress blog is hosted on Subdirectory WordPress, than add this line your wp-config.php

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');

52Enable keep Alive

Keep alive is only of favorite optimization of WordPress. Since, it allows web browser to make connection without any stoppage. Some cheap hosting company may not allow you to do this. BTW, You can simply add this line in your WordPress .htaccess to Enable ‘Keep Alive’ facility.

<ifModule mod_headers.c>
Header set Connection keep-alive

53Deny Iframe

If you don’t want to allow other to republish your website under iframe, you can simply deny it for all external domains. In this way you can save your precious bandwidth of your Server. Open header.php of WordPress current theme; add following line between Meta tag.

<meta http-equiv="X-Frame-Options" content="SAMEORIGIN">

54Don’t use default WordPress Comment System

In the previous step 7, I have mentioned a solution for serving gravtar image from Consistent URL. If are using WordPress default comment system no doubt, your Database size will be large. For performance prospective, you can prefer Discus Comment system. It stores all comments at their own Server. It offers various login methods, so there are fewer chances of spam comments. Learn more about loading discus comments on click.
And, The Server side optimization end here.

55Protect your site From Brute-Force Attack

I think to reduce server load, you should not take this step lightly. Becase, it impact negative on first byte response time.

  1. Limit Access your wp-admin page with pssword or IP address.
  2. Use WordFence Security Plugin.
  3. Use JetPack Single Sign on feature and replace normal WordPress login page to secure WordPress login page.
  4. Use WordFence Security Plugin to have great firewall protection.

Optimizing WordPress Plugins

Now, the very interesting part you will learn from here about Optimizing WordPress plugins installation. You have to first manage all those plugins according to your requirements.

WordPress has blessing features of Plugins. Their some plugins are good and some plugin are bad too. Some plugin are useful, in other hand few plugins are just eating server resources. See this list of recommend plugins.
BTW, for optimizing WordPress plugin you have to implements some techniques, which really come handy.

56Is JetPack plugin really make slow? Let’s optimize it

The truth is yes and no. Both. It’s depend upon how you use it. Many people say that Jetack plugin make site very slow. So, I thought to share this tips in my first point. I’m also using JetPack on this blog, but my site is still fast. The secret is I use below simple code to filter its front-end CSS.
To remove unnecessary CSS code of JetPack

Go to Appearance > Theme Editor > functions.php

add_filter( 'jetpack_implode_frontend_css', '__return_false' );

This filter allows you don’t load CSS from any deactivated modules.


// First, make sure Jetpack doesn't concatenate all its CSS
add_filter( 'jetpack_implode_frontend_css', '__return_false' );
// Then, remove each CSS file, one at a time
// You probably won't need them all, unless you use all the modules, and all the themes! :)
// Some of these are also only loaded on specific admin pages, so it wouldn't affect your readers
function jeherve_remove_all_jp_css() {
        wp_deregister_style( 'AtD_style' );                    // After the Deadline
        wp_deregister_style( 'jetpack_likes' );                // Likes
        wp_deregister_style( 'jetpack_related-posts' );        // Related Posts
        wp_deregister_style( 'jetpack-carousel' );             // Carousel
        wp_deregister_style( 'grunion.css' );                  // Contact form
        wp_deregister_style( 'the-neverending-homepage' );     // Infinite Scroll
        wp_deregister_style( 'infinity-twentyten' );           // Infinite Scroll - Twenty Ten
        wp_deregister_style( 'infinity-twentyeleven' );        // Infinite Scroll - Twenty Eleven
        wp_deregister_style( 'infinity-twentytwelve' );        // Infinite Scroll - Twenty Twelve
        wp_deregister_style( 'infinity-twentythirteen' );      // Infinite Scroll - Twenty Thirteen
        wp_deregister_style( 'infinity-twentyfourteen' );      // Infinite Scroll - Twenty Fourteen
        wp_deregister_style( 'infinity-twentyfifteen' );       // Infinite Scroll - Twenty Fifteen
        wp_deregister_style( 'noticons' );                     // Notes
        wp_deregister_style( 'post-by-email' );                // Post by Email
        wp_deregister_style( 'publicize' );                    // Publicize
        wp_deregister_style( 'sharedaddy' );                   // Sharing
        wp_deregister_style( 'sharing' );                      // Sharing
        wp_deregister_style( 'stats_reports_css' );            // Stats
        wp_deregister_style( 'jetpack-widgets' );              // Widgets
        wp_deregister_style( 'jetpack-slideshow' );            // Slideshows
        wp_deregister_style( 'presentations' );                // Presentation shortcode
        wp_deregister_style( 'jetpack-subscriptions' );        // Subscriptions
        wp_deregister_style( 'tiled-gallery' );                // Tiled Galleries
        wp_deregister_style( 'widget-conditions' );            // Widget Visibility
        wp_deregister_style( 'jetpack_display_posts_widget' ); // Display Posts Widget
        wp_deregister_style( 'gravatar-profile-widget' );      // Gravatar Widget
        wp_deregister_style( 'widget-grid-and-list' );         // Top Posts widget
        wp_deregister_style( 'jetpack-widgets' );              // Widgets
add_action( 'wp_enqueue_scripts', 'jeherve_remove_all_jp_css' );

Source: https://gist.github.com/jeherve/df4e349a209d532a7978

Note: Remove only those module stylesheet which you are not using.

57Analyze Plugin Load

Before implementing my Plugin Optimization tips, first of all check Plugin Load using P3 Plugin Performance Profiler plugin. After Checking, you should remove all unusual and heavy plugin which doesn’t matters a lot for you and your visitors.

Now You can Load Selective Plugin using Plugin Organizer. It will help you to load selective plugin according to the requirement. For example, it doesn’t make sense to load Contact Form 7 plugin CSS, Akismet Plugin JS at every page. In WordPress, you can easily manage plugins to load according to post or page requirements. You can also manage order to load each and every plugins.

58Show Widgets without effecting Visitor Experience

100 placed Widgets on a single web page Sucks my brain too! Ha-ha so, manage it now efficiently. If you are addicted to show many widgets, you can use Display Widgets plugin that can manage on which page/post you want to show or hide each and every widget. It simply adds a checkbox just below every widget. Isn’t simple!

59If possible, don’t use Official Sharing or Follow Button

Yes you right read. Reasons explained below.- They are not being Mobile Friendly according to Google Developer guidelines.- Facebook like box plugin cause unusual redirect to landing page.- On other hand, Twitter follow buttons also cause same problem.– Twitter Follow button JavaScript load on web page in sync mode which affect all over speed of web page.

Solution: It is best idea keep those heavy resources below the fold or use other sharing plugin which can load in ASYNC mode.
For example, if you want to load Tweet button in async way, simply use this code

Takeaway: Platform.js you should load in async way.

60Best way to add YouTube Video Iframe

If you are using Google+, you might have noticed sometimes that G+ load YouTube Video thumbnail only instead of full iframe. When a user clicks on it then they load actual iframe. On the  same principle, you can do for your WordPress blog. Simply install the Plugin WP YouTube Lyte

It is important to have Best and optimised WordPress theme.
Server impact a lot on all over performance
Make use less Plugin as possible as.

Bonus tips: Using WP Super Cache plugin would be great for your WordPress Blog. Rest all, if anything left you may apply manually to increase your blog speed. If you enjoyed this post please SHARE


  1. WordPress Optimization « WordPress Codex
  2. Optimize Your WordPress For More Speed – SiteGround
  3. WordPress Optimization Guide | GTmetrix
  4. WordPress Performance Optimization – New Relic blog
  5. Optimize Your WordPress Website Using These Simple Tips | Elegant
  6. WordPress Optimization Bible | Prelovac.com
  7. Pagespeed – The tool and optimization guide – Varvy
  8. Make the Web Faster | Google Developers
  9. 18 Tips on How to Speed Up WordPress – KeyCDN”
  10. Optimize Your WordPress For More Speed – SiteGround
  11. 5 Quick Ways to Speed Up Your WordPress Site – WPMU DEV

If you know any more way to increase WordPress Speed or have you any suggestion, please let me know through comments. Thanks!


  1. Great post. I thought I was good at this too, but I learnt heaps. Well done, and thanks for sharing. I liked the F12 Chrome Audit tip the mosts. Didn’t know about that one.

  2. Hi Gulshan Kumar,

    This is great post. Thank you for such a wonderful details WordPress optimization post. Learnt lot of optimization tweaks.
    I wanted to disable hotlinks, but I can't see the code to add in .htaccess file. I guess you have missed to add that. 🙂

    BTW, thanks again this has tremendously improved my site speed and performance.

  3. It seems that you are thoroughly a software professional. Not all bloggers will be familiar with the software part behind a blog. Great post by the way.

  4. I have put this in function.php
    // Remove Query String
    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 );

    and my site is not reachable now showing 500 HTTP error.
    plz, help.

  5. I have been looking for these stuffs. Found some valuable information from your page. Website speed plays a great role in keeping the visitor for a long time on the site.

  6. Great article bro. This is what i was looking for Everything at one place in simple way. Soon I will try to implement all these methods

  7. Really Nice article. I found more points than any other speed optimization posts.
    I followed some of your points now my page speed is below 700ms. before it was 2.10s. Thanks for this awesome article, sure i will share this with my blogger friends.

  8. This is a great resource – bookmarked since I can’t implement everything in one go. I noticed a huge jump in my page speed score when I used a similar plugin called WPSmush.it to reduce images.

  9. Article is great but i use Nginx for my blogs, can you provides alternative of .htaccess codes for nginx
    BTW, For removing Query String i use following code in my blogs
    /* Script Version remover */
    function gk_remove_script_version( $src ){
    return remove_query_arg( ‘ver’, $src );
    add_filter( ‘script_loader_src’, ‘gk_remove_script_version’, 15, 1 );
    add_filter( ‘style_loader_src’, ‘gk_remove_script_version’, 15, 1 );

  10. Hi there Gulshan,

    This is a detailed blog about speeding wordpress website. It took me about 40 minutes to implement these ‘killing’ techniques into my blog.

    But that’s nothing, the important thing is that my website is know rocking with speed. Thanks to you.

    Keep up the good work.

    Cheers, Clay.

  11. Hi Gulshan,
    Thanks for this complete A -Z optimization tips. You really nailed it, great article.

    Feedback: As you have written many code block in this article, one have to copy it and try it. You have disable mouse click and this is very very irritating for me a reader. Rest everything is great excellent article.

  12. The best thing that caught my attention and forced to land on this page is heading of this article. The post informative in terms of technicalities. As the heading suggest 50+ clever tips. The tips are of great use. One can experiment on them. Before coming on this page I read article by team of template toaster. They presented the article in well but did not include the technical part. As we all know programmers are only hungry for coding.

  13. Hi Gulshan, very comprehensive guide. Really Great job.
    Regarding html minification, seems that it doesn’t work
    What about something simpler like that :

    function sanitize_output($buffer) {

    $buffer = str_replace(array(“\r\n”, “\n”,”\r”,”\t”), “”, $buffer);

    return $buffer;



    • Please use Autoptimize plugin, it’s free and comes with good support by its author. I am 100% sure, it will work great for you. I am personally using on this plugin, so far no any problem.

      Thank you so much for your comment. I really appreciate your kind feedback. I have taken in note, and will try to improve at that point.