Faster Webpage Loading

Ever wonder putting some lines of code can extremely increase your website load time with no more efforts and can optimise your overall SEO too.

Some Data From 2020

Average Data Of 2020

Having average WebPage time can increase User Experience if the site can’t load in minimal time than visitor losses their attraction and there are high chances they won’t come back or use less your site.

So, we are not going deep in this let’s move to the main topic of how to decrease the load time for webpages/faster webpage loading.

Diagnosis

Before we go further let’s diagnosis your site and check why your site not loading fast and check your site’s Performance grade.

Let’s Headover to https://tools.pingdom.com

https://tools.pingdom.com

Basically, it will display all the possible outcome of websites like Performance Grade, Page Size, Loading Time and Requests.

Let’s have a look at our result

Pingdom website test result of our blog

Looks like our overall performance grade is not terrible and we almost had an “ A Grade “

Gzip

Gzip is a lossless data compression utility, we can use this to serve compress data to the users and browser automatically Decompress it itself.

Gzip has an average 77% compress ratio and that’s enough for making your site SEO and user friendly.

You can use Gzip with basic 2 methods

Edit .htaccess in your site root dir

Open .htaccess file in your website root dir, if you don’t have than create it.

Gzip does’t compress already compress files like ZIP, PNG and so on.

<IfModule deflate_module>
    # Enable compression for the following file types.
    AddOutputFilterByType            \
     DEFLATE                         \
      application/javascript         \
      text/css                       \
      text/html                      \
      text/javascript                \
      text/plain                     \
      text/xml
</IfModule>

Edit your main .php

<?php
// Put this code on top of your main .php file
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
    ob_start();
} elseif (strpos(' ' . $_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') == false) {
    if (strpos(' ' . $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') == false) {
        ob_start();
    } elseif (!ob_start("ob_gzhandler")) {
        ob_start();
    }
} elseif (!ob_start("ob_gzhandler")) {
    ob_start();
}
?>

Open your main .php file or your header file and put the following code on the top of all.

Now, lets check Gzip is working or not.

Let’s Handover to https://www.giftofspeed.com/gzip-test

https://www.giftofspeed.com/gzip-test/

The result basically displays compress ratio, compression time and many more things let’s have a look at over blog result.

Gzip checker result of over blog

Now, not in the list but you can use this method to sightly improve your load time by caching CSS, images and JS files to users’ local storage with simply editing .htaccess again.

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
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>

This will let the browser automatically load some content from local storage rather than requesting it from the server.

Conclusion

By using compression and caching can improve your overall page load time.

If you don’t know how to use all the above methods and want to improve your site’s performance than hire us.

We will make all the things perfect, Email us at [email protected]

If you have any further query comment below and don’t forget to share this article to your web developer friend.

< Happy Coding />